[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)
if activated?
@paths_map ||= {}
@paths_map[path] ||=
begin
fullpath = nil
suffixes = Gem.suffixes
if suffixes.find do |suf|
full_require_paths.find do |dir|
File.file?(fullpath = "#{dir}/#{path}#{suf}")
end
end
fullpath
end
Gem.suffixes.each do |suf|
full_require_paths.each do |dir|
fullpath = "#{dir}/#{path}#{suf}"
next unless File.file?(fullpath)
@paths_map[path] ||= fullpath
end
end
@paths_map[path]
end
end

View File

@ -1031,9 +1031,10 @@ class Gem::Specification < Gem::BasicSpecification
def self.find_by_path(path)
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
end || NOT_FOUND)
end || NOT_FOUND
spec.to_spec
end
@ -1050,9 +1051,10 @@ class Gem::Specification < Gem::BasicSpecification
end
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)
end || NOT_FOUND)
end || NOT_FOUND
stub.this
end