4 ms·
My Little Optimization: The Compiler Is Magic (2018)
- dannyw 7y agoAm I missing something, or are there no benchmarks in this?
- saagarjha 7y agoThere's a couple of links to Godbolt, which are a technically a bit hand-wavy but usually get the point across well enough.
- mannykannot 7y agoUntil 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."
- saagarjha 7y agoIf 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