1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[rubygems/rubygems] Do not replace the cache entry if there is already one

* That way, multiple lookups for the same file always return the same object.

https://github.com/rubygems/rubygems/commit/50a431b6db
This commit is contained in:
Benoit Daloze 2019-06-06 15:54:17 +02:00 committed by Hiroshi SHIBATA
parent 2453d16f5e
commit 05ae2c11fa
No known key found for this signature in database
GPG key ID: F9CF13417264FAC2

View file

@ -1124,7 +1124,12 @@ class Gem::Specification < Gem::BasicSpecification
if Gem::Specification === _spec
_spec.loaded_from = File.expand_path file.to_s
LOAD_CACHE_MUTEX.synchronize do
LOAD_CACHE[file] = _spec
prev = LOAD_CACHE[file]
if prev
_spec = prev
else
LOAD_CACHE[file] = _spec
end
end
return _spec
end