bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: uniq i18n implementation


From: Paul Eggert
Subject: Re: uniq i18n implementation
Date: Mon, 14 Aug 2006 09:22:31 -0700
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux)

Pádraig Brady <address@hidden> 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  <address@hidden>

        * 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
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]