ruby-changes:47808
From: naruse <ko1@a...>
Date: Sat, 16 Sep 2017 02:00:55 +0900 (JST)
Subject: [ruby-changes:47808] naruse:r59926 (trunk): Find.find -> Use Dir.children instead of Dir.entries
naruse 2017-09-16 02:00:49 +0900 (Sat, 16 Sep 2017) New Revision: 59926 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=59926 Log: 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@g...> https://github.com/ruby/ruby/pull/1697 fix GH-1697 [Feature #13896] Modified files: trunk/lib/find.rb Index: lib/find.rb =================================================================== --- lib/find.rb (revision 59925) +++ lib/find.rb (revision 59926) @@ -55,14 +55,13 @@ module Find https://github.com/ruby/ruby/blob/trunk/lib/find.rb#L55 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 } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/