Use phf
for primitive function lookup
#174
Labels
meta-good first issue
Good for newcomers
theme-internals
Relates to internal operations of the language
type-enhancement
New feature or request
Literal showerthought: why should we have to hash our primitive function names to look up their associated implementation if the list is going to be static? Surely we can build something that doesn't require extra hashing step and can map directly to an index.
And sure enough, it sounds like there's a better static map data structure for this. I found the
phf
crate after a very non-exaustive search. They even give a very similar example of looking up language keywords.An added benefit of this is that it can be purely static. No lazy static or
LazyLock
needed, which should simplify this code even further and avoid the first-time-access cost of building the map (although I'm sure this cost is negligible in the current state).The text was updated successfully, but these errors were encountered: