From b2996b30d9e868f1d28d45849c26fbad65d2be2a Mon Sep 17 00:00:00 2001 From: naruse Date: Fri, 15 Sep 2017 17:00:49 +0000 Subject: [PATCH] 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 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 --- lib/find.rb | 3 +-- 1 file changed, 1 insertion(+), 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 }