Mercurial > hg > octave-lyh > gnulib-hg
changeset 10482:e8d1a5b2c49c
fts: tweak inode comparison function
* lib/fts.c (fts_compare_ino): Sort on increasing, not decreasing
inode numbers, as documented.
SCALAR(0xeb1b20)
author | Jim Meyering <meyering@redhat.com> |
---|---|
date | Fri, 26 Sep 2008 13:43:00 +0200 |
parents | 47fe4e48e158 |
children | 5a24031ebf7d |
files | ChangeLog lib/fts.c |
diffstat | 2 files changed, 7 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2008-09-26 Jim Meyering <meyering@redhat.com> + fts: tweak inode comparison function + * lib/fts.c (fts_compare_ino): Sort on increasing, not decreasing + inode numbers, as documented. + fts: sort dirent entries on inode number before traversing This avoids a quadratic, seek-related performance penalty when operating on a directory containing many entries (measurable at 10k; @@ -12,6 +16,7 @@ (dirent_inode_sort_may_be_useful, fts_compare_ino): Likewise. (fts_build): Set the stat.st_ino member from D_INO. If it is likely to be useful, sort dirent entries on inode number. + * m4/fts.m4 (gl_FUNC_FTS_CORE): Check for fstatfs, sys/vfs.h, and the struct statfs.f_type member. * modules/fts (Depends-on): Add d-ino.
--- a/lib/fts.c +++ b/lib/fts.c @@ -981,8 +981,8 @@ static int fts_compare_ino (struct _ftsent const **a, struct _ftsent const **b) { - return (a[0]->fts_statp->st_ino < b[0]->fts_statp->st_ino ? 1 - : b[0]->fts_statp->st_ino < a[0]->fts_statp->st_ino ? -1 : 0); + return (a[0]->fts_statp->st_ino < b[0]->fts_statp->st_ino ? -1 + : b[0]->fts_statp->st_ino < a[0]->fts_statp->st_ino ? 1 : 0); } /*