
My Little Optimization: The Compiler Is Magic (2018) - luu
http://belkadan.com/blog/2018/03/My-Little-Optimization/
======
saagarjha
If you're looking to do this kind of matching with a large number of strings,
you may want to look at Aho-Corasick:
[https://en.wikipedia.org/wiki/Aho–Corasick_algorithm](https://en.wikipedia.org/wiki/Aho–Corasick_algorithm)

------
dannyw
Am I missing something, or are there no benchmarks in this?

~~~
saagarjha
There's a couple of links to Godbolt, which are a technically a bit hand-wavy
but usually get the point across well enough.

~~~
mannykannot
Until I looked at that, I could not figure out what justification existed for
the author's claim that "It turns out that simply switching to string_view
gave the compiler enough information to automatically turn the code I had way
back at the beginning into the switch-on-length variant."

