mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[rubygems/rubygems] Stop using a constant for something not constant
https://github.com/rubygems/rubygems/commit/5cb0b9d9b8
This commit is contained in:
parent
a5cd4a0568
commit
4bc69a25f3
1 changed files with 8 additions and 12 deletions
|
@ -102,12 +102,8 @@ class Gem::Specification < Gem::BasicSpecification
|
||||||
today = Time.now.utc
|
today = Time.now.utc
|
||||||
TODAY = Time.utc(today.year, today.month, today.day) # :nodoc:
|
TODAY = Time.utc(today.year, today.month, today.day) # :nodoc:
|
||||||
|
|
||||||
# rubocop:disable Style/MutableConstant
|
@load_cache = {} # :nodoc:
|
||||||
LOAD_CACHE = {} # :nodoc:
|
@load_cache_mutex = Thread::Mutex.new
|
||||||
# rubocop:enable Style/MutableConstant
|
|
||||||
LOAD_CACHE_MUTEX = Thread::Mutex.new
|
|
||||||
|
|
||||||
private_constant :LOAD_CACHE if defined? private_constant
|
|
||||||
|
|
||||||
VALID_NAME_PATTERN = /\A[a-zA-Z0-9\.\-\_]+\z/.freeze # :nodoc:
|
VALID_NAME_PATTERN = /\A[a-zA-Z0-9\.\-\_]+\z/.freeze # :nodoc:
|
||||||
|
|
||||||
|
@ -758,8 +754,8 @@ class Gem::Specification < Gem::BasicSpecification
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.clear_load_cache # :nodoc:
|
def self.clear_load_cache # :nodoc:
|
||||||
LOAD_CACHE_MUTEX.synchronize do
|
@load_cache_mutex.synchronize do
|
||||||
LOAD_CACHE.clear
|
@load_cache.clear
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
private_class_method :clear_load_cache
|
private_class_method :clear_load_cache
|
||||||
|
@ -1110,7 +1106,7 @@ class Gem::Specification < Gem::BasicSpecification
|
||||||
def self.load(file)
|
def self.load(file)
|
||||||
return unless file
|
return unless file
|
||||||
|
|
||||||
_spec = LOAD_CACHE_MUTEX.synchronize { LOAD_CACHE[file] }
|
_spec = @load_cache_mutex.synchronize { @load_cache[file] }
|
||||||
return _spec if _spec
|
return _spec if _spec
|
||||||
|
|
||||||
file = file.dup.tap(&Gem::UNTAINT)
|
file = file.dup.tap(&Gem::UNTAINT)
|
||||||
|
@ -1125,12 +1121,12 @@ class Gem::Specification < Gem::BasicSpecification
|
||||||
|
|
||||||
if Gem::Specification === _spec
|
if Gem::Specification === _spec
|
||||||
_spec.loaded_from = File.expand_path file.to_s
|
_spec.loaded_from = File.expand_path file.to_s
|
||||||
LOAD_CACHE_MUTEX.synchronize do
|
@load_cache_mutex.synchronize do
|
||||||
prev = LOAD_CACHE[file]
|
prev = @load_cache[file]
|
||||||
if prev
|
if prev
|
||||||
_spec = prev
|
_spec = prev
|
||||||
else
|
else
|
||||||
LOAD_CACHE[file] = _spec
|
@load_cache[file] = _spec
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return _spec
|
return _spec
|
||||||
|
|
Loading…
Add table
Reference in a new issue