Pádraig Brady <[EMAIL PROTECTED]> writes:

> There seems to be serious overhead with strcoll on glibc-2.3.5-10 at least.

We can fix the performance problem for that particular test case as
follows.  I installed this (diff -pubw format):

2006-08-14  Paul Eggert  <[EMAIL PROTECTED]>

        * memcoll.c (memcoll): Optimize for the common case where the
        arguments are bytewise equal.

--- memcoll.c.~1.13.~   2005-09-21 23:05:39.000000000 -0700
+++ memcoll.c   2006-08-14 09:18:44.000000000 -0700
@@ -38,6 +38,14 @@ memcoll (char *s1, size_t s1len, char *s
 
 #if HAVE_STRCOLL
 
+  /* strcoll is slow on many platforms, so check for the common case
+     where the arguments are bytewise equal.  Otherwise, walk through
+     the buffers using strcoll on each substring.  */
+
+  if (s1len == s2len && memcmp (s1, s2, s1len) == 0)
+    diff = 0;
+  else
+    {
   char n1 = s1[s1len];
   char n2 = s2[s2len];
 
@@ -71,6 +79,7 @@ memcoll (char *s1, size_t s1len, char *s
 
   s1[s1len - 1] = n1;
   s2[s2len - 1] = n2;
+    }
 
 #else
 


_______________________________________________
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils

Reply via email to