inturn
Efficient, performant, thread-safe bytes/string interning.
This crate was designed to have a lock-free mapping of symbols back to their original string.
It currently uses dashmap for deduplicating strings,
and a lock-free stack to map the string index (symbol) back to the string bytes.
It supports interning any &str/&[u8] by allocating it internally in an efficient arena when encountered for the first time,
or &'static str/&'static [u8] without allocation.
A *_mut variant of each API is provided which side-step any locks,
for e.g. initializing the interner with a static set of strings to pre-intern.
Examples
Basic str interning (the same API is available with BytesInterner for [u8]):
use Interner;
let interner = new;
let hello = interner.intern;
assert_eq!;
assert_eq!;
let world = interner.intern;
assert_eq!;
assert_eq!;
let hello2 = interner.intern;
assert_eq!;
assert_eq!;