diff options
author | Samuel Giddins <[email protected]> | 2023-09-18 12:47:01 -0700 |
---|---|---|
committer | git <[email protected]> | 2023-10-07 16:04:42 +0000 |
commit | bf71b0eda54b551db023cda9051b9be218c0f75d (patch) | |
tree | 74474cc9a3691e9af899fb69ff7f6616ecf96a43 /lib/rubygems/query_utils.rb | |
parent | 5810304c2edce3f9e889b4f55cf5c442a92d1a48 (diff) |
[rubygems/rubygems] Optimize allocations in Gem::Version
From running in a random rails app I have locally, here are the changes
1) for `bundle lock --update --bundler` (forcing Bundler to go through
dependency resolution)
```
==> memprof.after.txt <==
Total allocated: 2.98 MB (48307 objects)
Total retained: 1.21 MB (16507 objects)
==> memprof.before.txt <==
Total allocated: 12.62 MB (198506 objects)
Total retained: 1.30 MB (23133 objects)
```
2) for `bin/rails runner true` (essentially only bundler/setup)
```
==> memprof.after.txt <==
Total allocated: 59.50 kB (1017 objects)
Total retained: 25.08 kB (362 objects)
==> memprof.before.txt <==
Total allocated: 561.82 kB (8575 objects)
Total retained: 27.28 kB (513 objects)
```
https://github.com/rubygems/rubygems/commit/35c8ed2cb8
Diffstat (limited to 'lib/rubygems/query_utils.rb')
-rw-r--r-- | lib/rubygems/query_utils.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/rubygems/query_utils.rb b/lib/rubygems/query_utils.rb index 9a6a736461..a95a759401 100644 --- a/lib/rubygems/query_utils.rb +++ b/lib/rubygems/query_utils.rb @@ -311,8 +311,8 @@ module Gem::QueryUtils label = "Installed at" specs.each do |s| version = s.version.to_s - version << ", default" if s.default_gem? - entry << "\n" << " #{label} (#{version}): #{s.base_dir}" + default = ", default" if s.default_gem? + entry << "\n" << " #{label} (#{version}#{default}): #{s.base_dir}" label = " " * label.length end end |