diff options
| author | James Youngman <jay@gnu.org> | 2008-11-30 23:18:25 +0000 |
|---|---|---|
| committer | James Youngman <jay@gnu.org> | 2008-11-30 23:18:25 +0000 |
| commit | acb82fe44369c108b43ec3e805aa94bf28352d0a (patch) | |
| tree | e9ae816fb883c31b7f92c1a6b9989f9fd04c3b7e | |
| parent | cd1230709ec97809cf8ce73813197e7069d00d91 (diff) | |
| download | findutils-acb82fe.tar.gz | |
Apply patch from Jim Meyering: Pass file type information in dirent.d_type from fts to find in order to avoid extra stat calls.
| -rw-r--r-- | ChangeLog | 13 | ||||
| -rw-r--r-- | NEWS | 5 | ||||
| -rw-r--r-- | find/ftsfind.c | 8 | ||||
| -rw-r--r-- | import-gnulib.config | 2 |
4 files changed, 23 insertions, 5 deletions
@@ -1,3 +1,16 @@ +2008-11-30 Jim Meyering <meyering@redhat.com> + + Pass file type information in dirent.d_type from fts to find. + * find/ftsfind.c (consider_visiting): When fts provides usable + dirent.d_type information, and the only stat information required + by find's predicates is the file-type information normally found + in stat.st_mode (that is, not the permissions information), skip + the now-redundant stat calls. This change is useful only with the + very latest version of fts.c from gnulib. Requires gnulib version + d4b129b8e5f8a8d1198020fd6fc79310d305936c or later. + * find/ftsfind.c (find): Set state.have_type if fts returned type + information. + 2008-11-08 James Youngman <jay@gnu.org> * import-gnulib.config (gnulib_version): Update version of gnulib, @@ -15,6 +15,11 @@ Performance imporvements may only exist for some find command lines (performance testing was done for the fts implementation itself but we haven't done the analogous performance tests in find). +File type information is also passed back from fts to find, saving +calls to the stat system call for find command lines which don't need +the stat information. This provides a performance improvement for +common cases like "find . -type d". + * Major changes in release 4.5.2, 2008-09-07 ** Bug Fixes diff --git a/find/ftsfind.c b/find/ftsfind.c index 543b80f..e505518 100644 --- a/find/ftsfind.c +++ b/find/ftsfind.c @@ -472,8 +472,8 @@ consider_visiting(FTS *p, FTSENT *ent) || ent->fts_info == FTS_NS /* e.g. symlink loop */) { assert (!state.have_stat); - assert (!state.have_type); - state.type = mode = 0; + assert (state.type != 0); + mode = state.type; } else { @@ -615,8 +615,8 @@ find(char *arg) while ( (ent=fts_read(p)) != NULL ) { state.have_stat = false; - state.have_type = false; - state.type = 0; + state.have_type = !!ent->fts_statp->st_mode; + state.type = state.have_type ? ent->fts_statp->st_mode : 0; consider_visiting(p, ent); } fts_close(p); diff --git a/import-gnulib.config b/import-gnulib.config index 31efdfd..71c4d66 100644 --- a/import-gnulib.config +++ b/import-gnulib.config @@ -1,7 +1,7 @@ # findutils gnulib.config -*- sh -*- # What version of gnulib to use? -gnulib_version="c1591bd579afdb3ac8ee16375d1f6473d0e26e13" +gnulib_version="d4b129b8e5f8a8d1198020fd6fc79310d305936c" destdir="gnulib" # Random extra gnulib files needed for findutils. |
