[rubygems/rubygems] Reduce array allocations when loading definition
The same array was being re-created in a loop (as well as the `generic_local_platform`), which is avoidable by hoisting it to a frozen array created once https://github.com/rubygems/rubygems/commit/009a3c6d0d
This commit is contained in:
parent
a607d62d8c
commit
0ed55bf097
@ -245,8 +245,9 @@ module Bundler
|
|||||||
end
|
end
|
||||||
|
|
||||||
def filter_relevant(dependencies)
|
def filter_relevant(dependencies)
|
||||||
|
platforms_array = [generic_local_platform].freeze
|
||||||
dependencies.select do |d|
|
dependencies.select do |d|
|
||||||
d.should_include? && !d.gem_platforms([generic_local_platform]).empty?
|
d.should_include? && !d.gem_platforms(platforms_array).empty?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -270,10 +271,16 @@ module Bundler
|
|||||||
|
|
||||||
def dependencies_for(groups)
|
def dependencies_for(groups)
|
||||||
groups.map!(&:to_sym)
|
groups.map!(&:to_sym)
|
||||||
current_dependencies.reject do |d|
|
deps = current_dependencies # always returns a new array
|
||||||
(d.groups & groups).empty?
|
deps.select! do |d|
|
||||||
|
if RUBY_VERSION >= "3.1"
|
||||||
|
d.groups.intersect?(groups)
|
||||||
|
else
|
||||||
|
!(d.groups & groups).empty?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
deps
|
||||||
|
end
|
||||||
|
|
||||||
# Resolve all the dependencies specified in Gemfile. It ensures that
|
# Resolve all the dependencies specified in Gemfile. It ensures that
|
||||||
# dependencies that have been already resolved via locked file and are fresh
|
# dependencies that have been already resolved via locked file and are fresh
|
||||||
|
@ -48,10 +48,13 @@ module Bundler
|
|||||||
@autorequire = Array(options["require"] || []) if options.key?("require")
|
@autorequire = Array(options["require"] || []) if options.key?("require")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
RUBY_PLATFORM_ARRAY = [Gem::Platform::RUBY].freeze
|
||||||
|
private_constant :RUBY_PLATFORM_ARRAY
|
||||||
|
|
||||||
# Returns the platforms this dependency is valid for, in the same order as
|
# Returns the platforms this dependency is valid for, in the same order as
|
||||||
# passed in the `valid_platforms` parameter
|
# passed in the `valid_platforms` parameter
|
||||||
def gem_platforms(valid_platforms)
|
def gem_platforms(valid_platforms)
|
||||||
return [Gem::Platform::RUBY] if force_ruby_platform
|
return RUBY_PLATFORM_ARRAY if force_ruby_platform
|
||||||
return valid_platforms if @platforms.empty?
|
return valid_platforms if @platforms.empty?
|
||||||
|
|
||||||
valid_platforms.select {|p| expanded_platforms.include?(GemHelpers.generic(p)) }
|
valid_platforms.select {|p| expanded_platforms.include?(GemHelpers.generic(p)) }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user