Find.find -> Use Dir.children instead of Dir.entries
Dir.children is available since Feature #11302. Find.find can use of the new list (having no '.' neither '..' entries), making now superflous an if statement. This change can improve the performance of Find.find when the path has lots of entries (thousands?). https://bugs.ruby-lang.org/issues/11302 patched by Espartaco Palma <esparta@gmail.com> https://github.com/ruby/ruby/pull/1697 fix GH-1697 [Feature #13896] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59926 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
40f3c519d5
commit
b2996b30d9
@ -55,14 +55,13 @@ module Find
|
||||
end
|
||||
if s.directory? then
|
||||
begin
|
||||
fs = Dir.entries(file, encoding: enc)
|
||||
fs = Dir.children(file, encoding: enc)
|
||||
rescue Errno::ENOENT, Errno::EACCES, Errno::ENOTDIR, Errno::ELOOP, Errno::ENAMETOOLONG
|
||||
raise unless ignore_error
|
||||
next
|
||||
end
|
||||
fs.sort!
|
||||
fs.reverse_each {|f|
|
||||
next if f == "." or f == ".."
|
||||
f = File.join(file, f)
|
||||
ps.unshift f.untaint
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user