Skip to content

Commit 8e78830

Browse files
deivid-rodriguezsegiddins
authored andcommitted
[rubygems/rubygems] Lazily parse dependencies in EndpointSpecification
Since not every dependency gets referenced. When resolving from scratch a Gemfile including only `"gem "rails", "~> 8.0.1"`, I get the following results: ### Before Total allocated: 295.01 MB (3624335 objects) Total retained: 119.31 MB (1364474 objects) ### After Total allocated: 288.21 MB (3498515 objects) Total retained: 119.10 MB (1357976 objects) ruby/rubygems@61eee39d81 Co-authored-by: Samuel Giddins <[email protected]>
1 parent c833706 commit 8e78830

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/bundler/endpoint_specification.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,17 @@ class EndpointSpecification < Gem::Specification
66
include MatchRemoteMetadata
77

88
attr_reader :name, :version, :platform, :checksum
9-
attr_accessor :remote, :dependencies, :locked_platform
9+
attr_writer :dependencies
10+
attr_accessor :remote, :locked_platform
1011

1112
def initialize(name, version, platform, spec_fetcher, dependencies, metadata = nil)
1213
super()
1314
@name = name
1415
@version = Gem::Version.create version
1516
@platform = Gem::Platform.new(platform)
1617
@spec_fetcher = spec_fetcher
17-
@dependencies = dependencies.map {|dep, reqs| build_dependency(dep, reqs) }
18+
@dependencies = nil
19+
@unbuilt_dependencies = dependencies
1820

1921
@loaded_from = nil
2022
@remote_specification = nil
@@ -31,6 +33,10 @@ def fetch_platform
3133
@platform
3234
end
3335

36+
def dependencies
37+
@dependencies ||= @unbuilt_dependencies.map! {|dep, reqs| build_dependency(dep, reqs) }
38+
end
39+
3440
# needed for standalone, load required_paths from local gemspec
3541
# after the gem is installed
3642
def require_paths

0 commit comments

Comments
 (0)