dgkf / dgkf/R

Use `phf` for primitive function lookup

Open
#174 0 comments 0 reactions 0 assignees View on GitHub
meta-good first issue theme-internals type-enhancement
Dominant language
Rust
Stars
145
Forks
5
PR merge metrics
No merged PRs in 30d

Description

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](https://crates.io/crates/phf) 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).

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.