a18c4a9edb
It's still full of copy-paste but it should hopefully be easier to extend. Performance-wise it's about the same speed as the C++ one on my machine (!), mostly due to structural improvements such as using a hash table instead of an array. It does consume more memory however.