Comment

Comment by RcouF1uZ4gsC

While a neat trick, there are some caveats. First of all, the is_ascii_branchless can be written in c++ as

    return std::all_of(sv.begin(),sv.end(),[](uint8_t c){return c < 128;});
Once you do that, the differences in code complexity between this and the other solutions becomes even more stark.

Second, even the slow case is 2 GB/s. While the principle is helpful, the extra complexity may not be worth it in the vast majority of real life code.

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton