[rubygems/rubygems] Remove unnecessary remapping of dependencies

Sometimes we'll resolve using bare `Gem::Dependency` instances rather
than `Bundler::Dependency` instances, which is fine, simpler, and saves
some memory.

When resolving from scratch a Gemfile including only `"gem "rails", "~>
8.0.1"`, I get the following results:

### Before

Total allocated: 277.48 MB (3384318 objects)
Total retained:  117.53 MB (1338657 objects)

### After

Total allocated: 265.06 MB (3186053 objects)
Total retained:  116.98 MB (1302280 objects)

https://github.com/rubygems/rubygems/commit/c6dc2966c5
This commit is contained in:
David Rodríguez 2025-01-30 15:34:02 +01:00 committed by Hiroshi SHIBATA
parent 4c0cf2deed
commit 7fed6c887d
2 changed files with 3 additions and 11 deletions

View File

@ -36,6 +36,7 @@ module Bundler
def dependencies
@dependencies ||= @unbuilt_dependencies.map! {|dep, reqs| build_dependency(dep, reqs) }
end
alias_method :runtime_dependencies, :dependencies
# needed for standalone, load required_paths from local gemspec
# after the gem is installed
@ -167,7 +168,7 @@ module Bundler
end
def build_dependency(name, requirements)
Gem::Dependency.new(name, requirements)
Dependency.new(name, requirements)
end
end
end

View File

@ -40,7 +40,7 @@ module Bundler
def dependencies
@dependencies ||= @specs.flat_map do |spec|
__dependencies(spec) + metadata_dependencies(spec)
spec.runtime_dependencies + metadata_dependencies(spec)
end.uniq.sort
end
@ -72,15 +72,6 @@ module Bundler
@specs.first
end
def __dependencies(spec)
dependencies = []
spec.dependencies.each do |dep|
next if dep.type == :development
dependencies << Dependency.new(dep.name, dep.requirement)
end
dependencies
end
def metadata_dependencies(spec)
[
metadata_dependency("Ruby", spec.required_ruby_version),