]> Savannah Git Hosting - gnulib.git/commitdiff
localeinfo: ->simple would be wrong for LC_ALL=C
authorJim Meyering <meyering@fb.com>
Tue, 31 Dec 2019 07:23:42 +0000 (23:23 -0800)
committerJim Meyering <meyering@fb.com>
Tue, 31 Dec 2019 07:23:42 +0000 (23:23 -0800)
That would lead to using unnecessary and expensive code paths in dfa.c.
* lib/localeinfo.c (using_simple_locale): Fix recently-introduced logic
error that would have made grep many times slower in the C locale.
With this change, and a file created like this:
  yes 00 | head -10000000 > in
Running grep as follows becomes more than 40 times faster:
  LC_ALL=C grep -Fw 0 in

ChangeLog
lib/localeinfo.c

index dccdf7a1a9149336247a8cae32381ffa281472bb..6f6e6190ceb3000c21ad940a78458eebef535609 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2019-12-30  Jim Meyering  <meyering@fb.com>
+
+       localeinfo: ->simple would be wrong for LC_ALL=C
+       That would lead to using unnecessary and expensive code paths in dfa.c.
+       * lib/localeinfo.c (using_simple_locale): Fix recently-introduced logic
+       error that would have made grep many times slower in the C locale.
+       With this change, and a file created like this:
+         yes 00 | head -10000000 > in
+       Running grep as follows becomes more than 40 times faster:
+         LC_ALL=C grep -Fw 0 in
+
 2019-12-30  Paul Eggert  <eggert@cs.ucla.edu>
 
        doc: document trouble with back-references
index 372530e014bbe66c4da04a802846a044cd356907..c22aca21f26ff0950cca4f02d222302024b76acd 100644 (file)
@@ -77,7 +77,7 @@ using_simple_locale (bool multibyte)
      where the native order is the collating-sequence order but there
      are multi-character collating elements.  */
   for (int i = 0; i < UCHAR_MAX; i++)
-    if (strcoll (((char []) {i, 0}), ((char []) {i + 1, 0})) <= 0)
+    if (0 <= strcoll (((char []) {i, 0}), ((char []) {i + 1, 0})))
       return false;
 
   return true;