This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH v2] speedup strcoll by using strdiff
- From: OndÅej BÃlka <neleai at seznam dot cz>
- To: Leonhard Holz <leonhard dot holz at web dot de>
- Cc: libc-alpha at sourceware dot org
- Date: Fri, 3 Apr 2015 17:15:24 +0200
- Subject: Re: [PATCH v2] speedup strcoll by using strdiff
- Authentication-results: sourceware.org; auth=none
- References: <550284F9 dot 6090503 at web dot de>
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;
}