From 0ed55bf09713299201caec3ba9d9ef7ba6e8526f Mon Sep 17 00:00:00 2001 From: Samuel Giddins Date: Mon, 27 Nov 2023 16:06:27 -0600 Subject: [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 --- lib/bundler/dependency.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib/bundler/dependency.rb') diff --git a/lib/bundler/dependency.rb b/lib/bundler/dependency.rb index 21a4564dcc..82c4c1866b 100644 --- a/lib/bundler/dependency.rb +++ b/lib/bundler/dependency.rb @@ -48,10 +48,13 @@ module Bundler @autorequire = Array(options["require"] || []) if options.key?("require") 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 # passed in the `valid_platforms` parameter 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? valid_platforms.select {|p| expanded_platforms.include?(GemHelpers.generic(p)) } -- cgit v1.2.3