Skip to content

Commit 7fed6c8

Browse files
deivid-rodriguezhsbt
authored andcommitted
[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) ruby/rubygems@c6dc2966c5
1 parent 4c0cf2d commit 7fed6c8

File tree

2 files changed

+3
-11
lines changed

2 files changed

+3
-11
lines changed

lib/bundler/endpoint_specification.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def fetch_platform
3636
def dependencies
3737
@dependencies ||= @unbuilt_dependencies.map! {|dep, reqs| build_dependency(dep, reqs) }
3838
end
39+
alias_method :runtime_dependencies, :dependencies
3940

4041
# needed for standalone, load required_paths from local gemspec
4142
# after the gem is installed
@@ -167,7 +168,7 @@ def parse_metadata(data)
167168
end
168169

169170
def build_dependency(name, requirements)
170-
Gem::Dependency.new(name, requirements)
171+
Dependency.new(name, requirements)
171172
end
172173
end
173174
end

lib/bundler/resolver/spec_group.rb

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def to_s
4040

4141
def dependencies
4242
@dependencies ||= @specs.flat_map do |spec|
43-
__dependencies(spec) + metadata_dependencies(spec)
43+
spec.runtime_dependencies + metadata_dependencies(spec)
4444
end.uniq.sort
4545
end
4646

@@ -72,15 +72,6 @@ def exemplary_spec
7272
@specs.first
7373
end
7474

75-
def __dependencies(spec)
76-
dependencies = []
77-
spec.dependencies.each do |dep|
78-
next if dep.type == :development
79-
dependencies << Dependency.new(dep.name, dep.requirement)
80-
end
81-
dependencies
82-
end
83-
8475
def metadata_dependencies(spec)
8576
[
8677
metadata_dependency("Ruby", spec.required_ruby_version),

0 commit comments

Comments
 (0)