fts: tweak inode comparison function
authorJim Meyering <meyering@redhat.com>
Fri, 26 Sep 2008 11:43:00 +0000 (13:43 +0200)
committerJim Meyering <meyering@redhat.com>
Fri, 26 Sep 2008 11:43:00 +0000 (13:43 +0200)
* lib/fts.c (fts_compare_ino): Sort on increasing, not decreasing
inode numbers, as documented.

SCALAR(0xeb1b20)

ChangeLog
lib/fts.c

index db626d3..2ee1db3 100644 (file)
--- 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.
index 3cf49fa..673693a 100644 (file)
--- a/lib/fts.c
+++ b/lib/fts.c
@@ -981,8 +981,8 @@ static bool dirent_inode_sort_may_be_useful (FTS const *sp) { return true; }
 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);
 }
 
 /*