summaryrefslogtreecommitdiff
path: root/lib/bundler/source
diff options
context:
space:
mode:
authorMartin Emde <martin.emde@gmail.com>2023-08-31 20:11:54 -0700
committergit <svn-admin@ruby-lang.org>2023-09-07 00:33:28 +0000
commit86b93f74819dc814a223cd179d15b4d46dc3fc7a (patch)
tree3c36bf87f2059a686998d98768b9c0697625fc89 /lib/bundler/source
parentaf1bedbbd93e952810149e79d7fa6c20960e5373 (diff)
[rubygems/rubygems] Improve efficiency of Index#use and #search_all
Rename Index#use(override = true) to #merge! Rename Index @all_specs to @duplicates, it is not actually all specs. @duplicates only holds specs that would have been overridden during a call to Index#use or Index#merge! Reduced dupes in @duplicates by not double adding the new spec to the index and the @duplicates during #merge! Reduce Array creation by using specialized methods when the one result or no results are needed from the search. https://github.com/rubygems/rubygems/commit/47e91125db
Diffstat (limited to 'lib/bundler/source')
-rw-r--r--lib/bundler/source/rubygems.rb14
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/bundler/source/rubygems.rb b/lib/bundler/source/rubygems.rb
index 8977edc7c0..dc82d1d33c 100644
--- a/lib/bundler/source/rubygems.rb
+++ b/lib/bundler/source/rubygems.rb
@@ -128,12 +128,12 @@ module Bundler
def specs
@specs ||= begin
# remote_specs usually generates a way larger Index than the other
- # sources, and large_idx.use small_idx is way faster than
- # small_idx.use large_idx.
- idx = @allow_remote ? remote_specs.dup : Index.new
- idx.use(cached_specs, :override_dupes) if @allow_cached || @allow_remote
- idx.use(installed_specs, :override_dupes) if @allow_local
- idx
+ # sources, and large_idx.merge! small_idx is way faster than
+ # small_idx.merge! large_idx.
+ index = @allow_remote ? remote_specs.dup : Index.new
+ index.merge!(cached_specs) if @allow_cached || @allow_remote
+ index.merge!(installed_specs) if @allow_local
+ index
end
end
@@ -276,7 +276,7 @@ module Bundler
fetch_names(api_fetchers, unmet_dependency_names, remote_specs)
- specs.use(remote_specs, false)
+ specs.use remote_specs
end
def dependency_names_to_double_check