summaryrefslogtreecommitdiff
path: root/lib/find.rb
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-09-15 17:00:49 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-09-15 17:00:49 +0000
commitb2996b30d9e868f1d28d45849c26fbad65d2be2a (patch)
treed6c204b5ef3697284cb33cf706049d8fccd4c5a3 /lib/find.rb
parent40f3c519d5f5cc805b7d97588edcbd96b099e9e2 (diff)
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
Diffstat (limited to 'lib/find.rb')
-rw-r--r--lib/find.rb3
1 files changed, 1 insertions, 2 deletions
diff --git a/lib/find.rb b/lib/find.rb
index 04c95601ff..f97cc1b836 100644
--- a/lib/find.rb
+++ b/lib/find.rb
@@ -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
}