From 7e7d1f0679d7cbfc43d4157435317ae2f961b995 Mon Sep 17 00:00:00 2001 From: Samuel Giddins Date: Tue, 24 Oct 2023 11:23:51 -0500 Subject: [rubygems/rubygems] Avoid regexp match on every call to `Gem::Platform.local` The result of `arch` would be ignored if `@local` is set, so wrap all the logic in `@local ||=` to short-circuit everything https://github.com/rubygems/rubygems/commit/b67d39f3e0 --- lib/rubygems/platform.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/rubygems/platform.rb b/lib/rubygems/platform.rb index 93e33383fd..5c5abdc2e2 100644 --- a/lib/rubygems/platform.rb +++ b/lib/rubygems/platform.rb @@ -13,9 +13,11 @@ class Gem::Platform attr_accessor :cpu, :os, :version def self.local - arch = RbConfig::CONFIG["arch"] - arch = "#{arch}_60" if /mswin(?:32|64)$/.match?(arch) - @local ||= new(arch) + @local ||= begin + arch = RbConfig::CONFIG["arch"] + arch = "#{arch}_60" if /mswin(?:32|64)$/.match?(arch) + new(arch) + end end def self.match(platform) -- cgit v1.2.3