|void||symap_free (Symap *map)|
|uint32_t||symap_map (Symap *map, const char *sym)|
|Symap *||symap_new ()|
|static uint32_t||symap_search (const Symap *map, const char *sym, bool *exact)|
|static char *||symap_strdup (const char *str)|
|uint32_t||symap_try_map (Symap *map, const char *sym)|
|const char *||symap_unmap (Symap *map, uint32_t id)|
Implementation of Symap, a basic symbol map (string interner).
This implementation is primitive, but has some desirable qualities: good (O(lg(n)) lookup performance for already-mapped symbols, minimal space overhead, extremely fast (O(1)) reverse mapping (ID to string), simple code, no dependencies.
The tradeoff is that mapping new symbols may be quite slow. In other words, this implementation is ideal for use cases with a relatively limited set of symbols, or where most symbols are mapped early. It will not fare so well with very dynamic sets of symbols. For that, you're better off with a tree-based implementation (and the associated space cost, especially if you need reverse mapping).
Definition in file symap.c.