Re:Cttrie – Compile-time trie-based string matching for C++
by convivialdingo on Friday September 14, 2018 @12:31PM
(#17988593)
Something we’ve used before is preprocessor string hashing similar to [1]. Basically we hash strings at compile time to ints and use those for our case statements. Word of caution though, there’s the possibility of collisions. It works great on a limited set of strings like XML tags and such.
1. http://lolengine.net/blog/2011/12/20/cpp-constant-string-has...
Re:Cttrie – Compile-time trie-based string matching for C++
by saagarjha on Friday September 14, 2018 @02:12PM
(#17989462)
You know, I don't quite understand the point the author is making there. They concede that the compiler is smart enough to elide memcpys, but not smart enough to vectorize their strlen function? What?
It allows you to write something like this: https://github.com/lpereira/lwan/blob/master/src/lib/lwan-ti... -- which is generated as a binary search by GCC.