Skip to main content

intern_cached_with

Function intern_cached_with 

Source
pub fn intern_cached_with<F>(
    source_id: u32,
    text_offset: u32,
    cold: F,
) -> Symbol
where F: FnOnce() -> Symbol,
Expand description

Cache an interned Symbol by (source_id, text_offset), computing it lazily via cold only on a cache miss.

Steady-state hit: FxHashMap u64 lookup — no string materialization, no string hashing. This lets the identifier-eval hot path avoid the per-lookup ident_text().to_string() heap allocation entirely, since the &str is only needed to intern on the (once-per-offset) cold miss.