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;
(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.
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);
}
/*