With some refactoring, the speed of the hash bashed implementation can probably be increased (maybe even drastically):
1) Ideally choose a hash that is "perfect" for the set of all keywords. So no hash value has more than one matching keyword
2) the important part:
Instead of a hash table containing function-refs, have a hash table with the keywords. (well keyword + function ref)
Then the compare with the keyword can be made before calling the function. That may saves a lot of unnecessary calls.
And if (1) the hash is perfect for the list of keywords, then the hash table only needs one entry per hash value. Otherwise a sorted list or prefix tree were needed.
Further more: the entries in the hash table could contain:
- keyword
- function (may be nil)
- type of ident (e.g. number, keyword, ...)
for keywords which only return a specific attribute, but do nothing else, no function needs to be called.