http://glfwtfwhlsm2u5pw3b7crist7bt7fwepj2wgv3n3b64unj22v5435tyd.onion/blog/2022/12/10/The-Incredible-speed-of-memchr.html
For small strings we see improvements of 2-3x, for mid-long strings, it is around 10x, and for long strings, we see over 30x speed improvements. Appendix Code Link to godbolt or here if godbolt ever looses the code: #include <benchmark/benchmark.h>
#include <cstring>
#include <string>
#include <iostream>
void* mymemchr(char* s, char c, int i) {
while(i--) {
if (*s++ == c) {
return s-1;
}
}
return nullptr;
}
void* myrawmemchr(char* s, char c) {
...