Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Bundler::Index efficiency by removing unnecessary creation and dups #6931

Merged
merged 3 commits into from
Sep 7, 2023

Conversation

martinemde
Copy link
Member

What was the end-user or developer problem that led to this PR?

Bundler::Source::Rubygems#fetch_names was always called with override_dupes set to false.
Bundler::Index had two versions of #use that did were semantically different enough to split into two methods.

What is your fix for the problem, implemented in this PR?

Refactor these methods to make them easier to understand.

Change the name of Index @all_specs to be called @duplicates because it does not contain all specs, but only specs that have been found as duplicates.

Make sure the following tasks are checked

@martinemde martinemde force-pushed the martinemde/fetch_names_never_overrides branch 5 times, most recently from 918f459 to 09bb1e4 Compare September 1, 2023 04:43
@martinemde martinemde changed the title Refactor Bundler index methods that predictably take the same boolean Improve Bundle::Index efficient by removing unnecessary creation and dups Sep 1, 2023
@martinemde martinemde changed the title Improve Bundle::Index efficient by removing unnecessary creation and dups Improve Bundle::Index efficiency by removing unnecessary creation and dups Sep 1, 2023
@martinemde martinemde force-pushed the martinemde/fetch_names_never_overrides branch from 09bb1e4 to c2e81e8 Compare September 1, 2023 04:46
@martinemde martinemde force-pushed the martinemde/fetch_names_never_overrides branch from c2e81e8 to 9ee5ee6 Compare September 1, 2023 17:19
@martinemde martinemde force-pushed the martinemde/fetch_names_never_overrides branch from 9ee5ee6 to 75166db Compare September 6, 2023 19:23
bundler/lib/bundler/index.rb Outdated Show resolved Hide resolved
bundler/lib/bundler/source/rubygems.rb Show resolved Hide resolved
@martinemde martinemde force-pushed the martinemde/fetch_names_never_overrides branch from 75166db to f12da3e Compare September 6, 2023 22:31
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.
When @allow_cached is true, @allow_local is always true,
therefore, the #installed_specs will always be merged after #cached_specs
is called. This makes starting with installed_specs.dup redundant.

When #cached_specs is called because @allow_remote is true and
@allow_cached is false, then installed_specs will be added after
cached_specs based on @allow_local.

We never need to add installed_specs here, so don't.
@martinemde martinemde force-pushed the martinemde/fetch_names_never_overrides branch from f12da3e to 49b38f9 Compare September 6, 2023 22:58
@martinemde martinemde merged commit 0e54343 into master Sep 7, 2023
92 checks passed
@martinemde martinemde deleted the martinemde/fetch_names_never_overrides branch September 7, 2023 00:33
@deivid-rodriguez deivid-rodriguez changed the title Improve Bundle::Index efficiency by removing unnecessary creation and dups Improve Bundler::Index efficiency by removing unnecessary creation and dups Sep 21, 2023
deivid-rodriguez pushed a commit that referenced this pull request Sep 21, 2023
…verrides

Improve Bundle::Index efficiency by removing unnecessary creation and dups

(cherry picked from commit 0e54343)
deivid-rodriguez pushed a commit that referenced this pull request Sep 21, 2023
…verrides

Improve Bundle::Index efficiency by removing unnecessary creation and dups

(cherry picked from commit 0e54343)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants