Skip to content

Commit

Permalink
[rubygems/rubygems] Use Array#concat in SpecSet#for to save memory
Browse files Browse the repository at this point in the history
On `rails/rails` repository Gemfile, running the following script

```
# script.rb
require "bundler/setup"
```

#### Before

```
➜  rails git:(main) ✗ BUNDLER_VERSION=2.4.0.dev ruby-memory-profiler --pretty --no-detailed --allocated-strings=0 --retained-strings=0 script.rb
Total allocated: 24.37 MB (207937 objects)
Total retained:  2.98 MB (34152 objects)
```

#### After

```
➜  rails git:(main) ✗ BUNDLER_VERSION=2.4.0.dev ruby-memory-profiler --pretty --no-detailed --allocated-strings=0 --retained-strings=0 script.rb
Total allocated: 22.27 MB (206856 objects)
Total retained:  2.98 MB (34152 objects)
```

rubygems/rubygems@2ea2523afd

Co-authored-by: Josh Nichols <josh.nichols@gusto.com>
  • Loading branch information
2 people authored and matzbot committed May 16, 2022
1 parent c380aac commit 641c383
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/bundler/spec_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def for(dependencies, check = false, match_current_platform = false)

specs_for_dep = spec_for_dependency(dep, match_current_platform)
if specs_for_dep.any?
specs += specs_for_dep
specs.concat(specs_for_dep)

specs_for_dep.first.dependencies.each do |d|
next if d.type == :development
Expand Down

0 comments on commit 641c383

Please sign in to comment.