[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
memcoll performance hack
From: |
Paul Eggert |
Subject: |
memcoll performance hack |
Date: |
Tue, 15 Aug 2006 14:50:08 -0700 |
User-agent: |
Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux) |
I installed this, from coreutils (diff -pubw format):
2006-08-15 Paul Eggert <address@hidden>
* lib/memcoll.c (memcoll): Optimize for the common case where the
arguments are bytewise equal.
--- lib/memcoll.c 19 Sep 2005 17:28:14 -0000 1.14
+++ lib/memcoll.c 15 Aug 2006 21:46:42 -0000
@@ -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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- memcoll performance hack,
Paul Eggert <=