This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[RFC] Improve strcasestr with strpbrk
- From: OndÅej BÃlka <neleai at seznam dot cz>
- To: libc-alpha at sourceware dot org
- Date: Wed, 13 May 2015 01:10:31 +0200
- Subject: [RFC] Improve strcasestr with strpbrk
- Authentication-results: sourceware.org; auth=none
Hi, I plan to also optimize strcasestr with similar heuristic as strstr
improvement that I just sent.
It needs some precomputing so I ask which path to take.
A simplest one would just check if tolower of characters in 0-128 range maps as C locale. Then I would add specialized assembly for strpbrk like
strasciibrk(s, n0, n1) - finds first byte that is either n0, n1 or
outside 0-128 byte range.
Second possibility would be calculate equivalence classes. Then we could
just replace strchr (s, n[0]) with strpbrk (s, equivalence_class (n[0]))
Problem is that calculating equivalence classes is expensive for
multibyte UTF so table would need to be saved to disk.
So which alternative should be used?