[PATCH v2] speedup strcoll by using strdiff
Ondřej Bílka
neleai@seznam.cz
Fri Apr 3 15:15:00 GMT 2015
On Fri, Mar 13, 2015 at 07:34:33AM +0100, Leonhard Holz wrote:
> This patch uses strdiff to skip over equal prefixes in strcoll. This
> is implemented for 8-bit character sets and UTF-8.
>
Almost ok for me.
I would rather do detection in setlocale by setting new value so you
could use say:
current->values[_NL_ITEM_INDEX (_NL_COLLATE_ENCODING_TYPE)].word;
Now it would be faster unless you have long running application that
uses lot of locales. Then linear browsing of list could be bottleneck.
Second request is moving strcoll to separate file due optimized
implementations.
Following should work for 64bit archs with little endian allowing
unaligned loads.
Also when strdiff is checked I will add patch that uses strdiff for
strcase*cmp as only powerpc and x86/64 have optimized assembly.
size_t
strdiff (char *x, char *y)
{
uint64_t *xp = (uint64_t *) x, *yp = (uint64_t *) y;
size_t i;
while (x[i] == y[i])
i++;
return 8 * i + (ffsl (x[i] ^ y[i]) - 1) / 8;
}
More information about the Libc-alpha
mailing list