From 7660884ffd3db05c74b2d656a8285e1081571bc9 Mon Sep 17 00:00:00 2001 From: akr Date: Sun, 6 Dec 2009 14:17:33 +0000 Subject: * lib/find.rb (Find.find): reduce stat system call. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@26028 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 ++++ lib/find.rb | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index b896b4416..1982f4cd5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Sun Dec 6 23:16:35 2009 Tanaka Akira + + * lib/find.rb (Find.find): reduce stat system call. + Sun Dec 6 16:02:15 2009 NARUSE, Yui * lib/webrick/httpservlet/filehandler.rb: escape filename of index. diff --git a/lib/find.rb b/lib/find.rb index ee96e526e..f9bc75415 100644 --- a/lib/find.rb +++ b/lib/find.rb @@ -39,9 +39,13 @@ module Find while file = paths.shift catch(:prune) do yield file.dup.taint - next unless File.exist? file + begin + s = File.lstat(file) + rescue SystemCallError + next + end begin - if File.lstat(file).directory? then + if s.directory? then d = Dir.open(file) begin for f in d -- cgit