[RFC] Improve strcasestr with strpbrk

Ondřej Bílka neleai@seznam.cz
Tue May 12 23:10:00 GMT 2015


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?



More information about the Libc-alpha mailing list