diff options
author | David RodrÃguez <deivid.rodriguez@riseup.net> | 2021-11-04 13:28:30 +0100 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2021-11-18 04:37:27 +0900 |
commit | 4bc69a25f3b317771a9ec5a3a60b1d7e13321bc0 (patch) | |
tree | 376ec092055f1c06a8d022f387daab19aecb6343 | |
parent | a5cd4a056896cbc47c59617305b1ee8e1b5b7911 (diff) | |
download | ruby-4bc69a25f3b317771a9ec5a3a60b1d7e13321bc0.tar.gz |
[rubygems/rubygems] Stop using a constant for something not constant
https://github.com/rubygems/rubygems/commit/5cb0b9d9b8
-rw-r--r-- | lib/rubygems/specification.rb | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb index e1c1a60b1f..2388354f67 100644 --- a/lib/rubygems/specification.rb +++ b/lib/rubygems/specification.rb @@ -102,12 +102,8 @@ class Gem::Specification < Gem::BasicSpecification today = Time.now.utc TODAY = Time.utc(today.year, today.month, today.day) # :nodoc: - # rubocop:disable Style/MutableConstant - LOAD_CACHE = {} # :nodoc: - # rubocop:enable Style/MutableConstant - LOAD_CACHE_MUTEX = Thread::Mutex.new - - private_constant :LOAD_CACHE if defined? private_constant + @load_cache = {} # :nodoc: + @load_cache_mutex = Thread::Mutex.new VALID_NAME_PATTERN = /\A[a-zA-Z0-9\.\-\_]+\z/.freeze # :nodoc: @@ -758,8 +754,8 @@ class Gem::Specification < Gem::BasicSpecification end def self.clear_load_cache # :nodoc: - LOAD_CACHE_MUTEX.synchronize do - LOAD_CACHE.clear + @load_cache_mutex.synchronize do + @load_cache.clear end end private_class_method :clear_load_cache @@ -1110,7 +1106,7 @@ class Gem::Specification < Gem::BasicSpecification def self.load(file) return unless file - _spec = LOAD_CACHE_MUTEX.synchronize { LOAD_CACHE[file] } + _spec = @load_cache_mutex.synchronize { @load_cache[file] } return _spec if _spec file = file.dup.tap(&Gem::UNTAINT) @@ -1125,12 +1121,12 @@ class Gem::Specification < Gem::BasicSpecification if Gem::Specification === _spec _spec.loaded_from = File.expand_path file.to_s - LOAD_CACHE_MUTEX.synchronize do - prev = LOAD_CACHE[file] + @load_cache_mutex.synchronize do + prev = @load_cache[file] if prev _spec = prev else - LOAD_CACHE[file] = _spec + @load_cache[file] = _spec end end return _spec |