diff options
author | David RodrÃguez <deivid.rodriguez@riseup.net> | 2022-05-13 11:26:20 +0200 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2022-05-16 17:24:14 +0900 |
commit | c380aac19d097f1d38d2299fe3f64567b42fb55d (patch) | |
tree | 8f43b5d6a0225b932a3a1f8d110fb0e076f34d08 /lib/bundler | |
parent | dccfff943c3ea9defd91647cfa3fd8714041bb5a (diff) |
[rubygems/rubygems] Improve `bundler/setup` performance again
On a different patch, it was noticed Ngam Pham that we are calling
`LazySpecification#hash` many times, and simply memoizing that led to a
very considerable performance improvement in his app.
I noticed though that we shouldn't be calling `LazySpecification#hash`
that many times, and I located the culprit at `SpecSet#for` where we
were deduplicating the partial aggregated result on every iteration. It
is enough to do it just once at the end.
This leads on a 12% speedup on Rails repository Gemfile vs the previous
8% I was getting from memoizing `LazySpecification#hash`. Also, after
this patch memoizing `LazySpecification#hash` has no effect in
performance anymore.
https://github.com/rubygems/rubygems/commit/68d00a9edd
Co-authored-by: Ngan Pham <ngan@users.noreply.github.com>
Diffstat (limited to 'lib/bundler')
-rw-r--r-- | lib/bundler/spec_set.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/bundler/spec_set.rb b/lib/bundler/spec_set.rb index a19d18388a..dc55e5eaed 100644 --- a/lib/bundler/spec_set.rb +++ b/lib/bundler/spec_set.rb @@ -24,7 +24,7 @@ module Bundler specs_for_dep = spec_for_dependency(dep, match_current_platform) if specs_for_dep.any? - match_current_platform ? specs += specs_for_dep : specs |= specs_for_dep + specs += specs_for_dep specs_for_dep.first.dependencies.each do |d| next if d.type == :development @@ -40,6 +40,8 @@ module Bundler specs << spec end + specs.uniq! unless match_current_platform + check ? true : specs end |