changeset 19585:359b539b5677

fts: add comment * lib/fts.c (fts_build): Explain why ==, not >. See remark by Bernhard Voelker in: https://lists.gnu.org/r/bug-gnulib/2018-04/msg00041.html
author Paul Eggert <eggert@cs.ucla.edu>
date Wed, 11 Apr 2018 16:27:03 -0700
parents 4f93d7f4b6ae
children e96868a495aa
files ChangeLog lib/fts.c
diffstat 2 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Apr 11 12:50:35 2018 -0700
+++ b/ChangeLog	Wed Apr 11 16:27:03 2018 -0700
@@ -1,5 +1,10 @@
 2018-04-11  Paul Eggert  <eggert@cs.ucla.edu>
 
+	fts: add comment
+	* lib/fts.c (fts_build): Explain why ==, not >.
+	See remark by Bernhard Voelker in:
+	https://lists.gnu.org/r/bug-gnulib/2018-04/msg00041.html
+
 	fts: fix bug in find across filesystems
 	This fixes a bug I introduced last summer.
 	Problem reported by Kamil Dudka in:
--- a/lib/fts.c	Wed Apr 11 12:50:35 2018 -0700
+++ b/lib/fts.c	Wed Apr 11 16:27:03 2018 -0700
@@ -1597,7 +1597,11 @@
                 /* If there are many entries, no sorting function has been
                    specified, and this file system is of a type that may be
                    slow with a large number of entries, arrange to sort the
-                   directory entries on increasing inode numbers.  */
+                   directory entries on increasing inode numbers.
+
+                   The NITEMS comparison uses ==, not >, because the test
+                   needs to be tried at most once once, and NITEMS will exceed
+                   the threshold after it is incremented below.  */
                 if (nitems == _FTS_INODE_SORT_DIR_ENTRIES_THRESHOLD
                     && !sp->fts_compar)
                   sort_by_inode = dirent_inode_sort_may_be_useful (cur, dir_fd);