When using fts there are too many calls to stat compared to oldfind.
One problem is the use of an uninitialized variable in
ftsfind.c:consider_visiting, see the patch below for a fix.  Another
problem is that with fts there is no way to distinguish state.have_stat
and state.have_type, ie. fts_read cannot report back the type of the
file without a full stat.  That means that a command like "find -type d"
will have to stat _every_ file, whereas without fts, but with working
d_type support it would only have to stat the directories.

Andreas.

2008-07-30  Andreas Schwab  <[EMAIL PROTECTED]>

        * find/ftsfind.c (consider_visiting): Remove use of statbuf when
        it is uninitialized.  Don't call fts_set with FTS_AGAIN since the
        condition can never be true.

--- find/ftsfind.c      04 Jun 2008 14:21:15 +0200      1.39
+++ find/ftsfind.c      30 Jul 2008 18:07:27 +0200      
@@ -388,7 +388,7 @@ consider_visiting(FTS *p, FTSENT *ent)
 {
   struct stat statbuf;
   mode_t mode;
-  int ignore, isdir;
+  int ignore;
   
   if (options.debug_options & DebugSearch)
     fprintf(stderr,
@@ -498,22 +498,6 @@ consider_visiting(FTS *p, FTSENT *ent)
 
   /* examine this item. */
   ignore = 0;
-  isdir = S_ISDIR(statbuf.st_mode)
-    || (FTS_D  == ent->fts_info)
-    || (FTS_DP == ent->fts_info)
-    || (FTS_DC == ent->fts_info);
-
-  if (isdir && (ent->fts_info == FTS_NSOK))
-    {
-      /* This is a directory, but fts did not stat it, so
-       * presumably would not be planning to search its
-       * children.  Force a stat of the file so that the
-       * children can be checked.
-       */
-      fts_set(p, ent, FTS_AGAIN);
-      return;
-    }
-
   if (options.maxdepth >= 0)
     {
       if (ent->fts_level >= options.maxdepth)

-- 
Andreas Schwab, SuSE Labs, [EMAIL PROTECTED]
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."


Reply via email to