aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2023-07-19 22:42:20 +0900
committergit <svn-admin@ruby-lang.org>2023-07-25 04:52:54 +0000
commit70eeec0cad7daa56bee91967657d7dd86ca36e18 (patch)
treecef3e4e22d1db0c91c1020fdc4b69d1357a6c554
parent1b27e7aa1fbd4c3c9a8640e94b1cd8818f4901d1 (diff)
downloadruby-70eeec0cad7daa56bee91967657d7dd86ca36e18.tar.gz
[rubygems/rubygems] Simplify double loop
https://github.com/rubygems/rubygems/commit/630dc02112
-rw-r--r--lib/rubygems/core_ext/kernel_require.rb10
1 files changed, 3 insertions, 7 deletions
diff --git a/lib/rubygems/core_ext/kernel_require.rb b/lib/rubygems/core_ext/kernel_require.rb
index d030f9d46d..c41ef70669 100644
--- a/lib/rubygems/core_ext/kernel_require.rb
+++ b/lib/rubygems/core_ext/kernel_require.rb
@@ -44,20 +44,16 @@ module Kernel
resolved_path = begin
rp = nil
load_path_check_index = Gem.load_path_insert_index - Gem.activated_gem_paths
- Gem.suffixes.each do |s|
- $LOAD_PATH[0...load_path_check_index].each do |lp|
+ Gem.suffixes.find do |s|
+ $LOAD_PATH[0...load_path_check_index].find do |lp|
safe_lp = lp.dup.tap(&Gem::UNTAINT)
if File.symlink? safe_lp # for backward compatibility
next
end
full_path = File.expand_path(File.join(safe_lp, "#{path}#{s}"))
- if File.file?(full_path)
- rp = full_path
- break
- end
+ rp = full_path if File.file?(full_path)
end
- break if rp
end
rp
end