[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
This commit is contained in:
Samuel Giddins 2023-10-24 11:23:51 -05:00 committed by git
parent b0a9707364
commit 7e7d1f0679

View File

@ -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)