Skip to content

Commit

Permalink
Merge pull request #7104 from rubygems/avoid-regexp-match-on-every-ca…
Browse files Browse the repository at this point in the history
…ll-to-gem-platform.local

Avoid regexp match on every call to `Gem::Platform.local`

(cherry picked from commit 6936dc1)
  • Loading branch information
segiddins authored and deivid-rodriguez committed Nov 8, 2023
1 parent e28856f commit 2b61cd0
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/rubygems/platform.rb
Expand Up @@ -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)
Expand Down

0 comments on commit 2b61cd0

Please sign in to comment.