From 51d0e5877283a260f994b05fde6411d39a49bc99 Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Sun, 20 Apr 2025 01:09:13 -0700 Subject: [PATCH] [rubygems/rubygems] Avoid unnecessary splat allocation Because get_push_scope is a method call, Ruby will allocate an array for *args even though it is not necessary to do so. Using a local variable avoids the allocation. Found by the performance warning in Ruby feature 21274. https://github.com/rubygems/rubygems/commit/0473c0cf32 --- lib/rubygems/commands/push_command.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/rubygems/commands/push_command.rb b/lib/rubygems/commands/push_command.rb index 726191377a..d2ce86703b 100644 --- a/lib/rubygems/commands/push_command.rb +++ b/lib/rubygems/commands/push_command.rb @@ -92,7 +92,8 @@ The push command will use ~/.gem/credentials to authenticate to a server, but yo private def send_push_request(name, args) - rubygems_api_request(*args, scope: get_push_scope) do |request| + scope = get_push_scope + rubygems_api_request(*args, scope: scope) do |request| body = Gem.read_binary name if options[:attestations].any? request.set_form([