[PATCH v12 14/31] string: Improve generic strrchr with memrchr and strlen
Wilco Dijkstra
Wilco.Dijkstra@arm.com
Thu Feb 2 19:54:01 GMT 2023
Hi Adhemerval,
STRRCHR (const char *s, int c)
{
+ return __memrchr (s, c, strlen (s) + 1);
}
LGTM
I did a quick check on AArch64 and the speedup vs the old generic version
on bench-strrchr is 9.9 times! It's ~15% slower overall than the assembler
strrchr.
While the benchmark is not perfect, it shows that if you have decent strlen
and memrchr then strlen+memchr gives a competitive strrchr.
Cheers,
Wilco
More information about the Libc-alpha
mailing list