[rubygems/rubygems] util/rubocop -A --only Style/MultilineMemoization

https://github.com/rubygems/rubygems/commit/c1f6e4a97b
This commit is contained in:
Hiroshi SHIBATA 2023-03-22 13:17:33 +09:00
parent 8a364b8512
commit bec069b0ca
Notes: git 2023-03-23 08:19:24 +00:00
2 changed files with 13 additions and 15 deletions

View File

@ -170,18 +170,14 @@ class Gem::BasicSpecification
def to_fullpath(path) def to_fullpath(path)
if activated? if activated?
@paths_map ||= {} @paths_map ||= {}
@paths_map[path] ||= Gem.suffixes.each do |suf|
begin full_require_paths.each do |dir|
fullpath = nil fullpath = "#{dir}/#{path}#{suf}"
suffixes = Gem.suffixes next unless File.file?(fullpath)
if suffixes.find do |suf| @paths_map[path] ||= fullpath
full_require_paths.find do |dir|
File.file?(fullpath = "#{dir}/#{path}#{suf}")
end
end
fullpath
end
end end
end
@paths_map[path]
end end
end end

View File

@ -1031,9 +1031,10 @@ class Gem::Specification < Gem::BasicSpecification
def self.find_by_path(path) def self.find_by_path(path)
path = path.dup.freeze path = path.dup.freeze
spec = @@spec_with_requirable_file[path] ||= (stubs.find do |s| spec = @@spec_with_requirable_file[path] ||= stubs.find do |s|
s.contains_requirable_file? path s.contains_requirable_file? path
end || NOT_FOUND) end || NOT_FOUND
spec.to_spec spec.to_spec
end end
@ -1050,9 +1051,10 @@ class Gem::Specification < Gem::BasicSpecification
end end
def self.find_active_stub_by_path(path) def self.find_active_stub_by_path(path)
stub = @@active_stub_with_requirable_file[path] ||= (stubs.find do |s| stub = @@active_stub_with_requirable_file[path] ||= stubs.find do |s|
s.activated? && s.contains_requirable_file?(path) s.activated? && s.contains_requirable_file?(path)
end || NOT_FOUND) end || NOT_FOUND
stub.this stub.this
end end