pub struct ShardedInterner { /* private fields */ }Expand description
Sharded string interner for concurrent use.
Uses fixed buckets to reduce lock contention while keeping Atom lookups O(1).
Implementations§
Source§impl ShardedInterner
impl ShardedInterner
Sourcepub fn new() -> ShardedInterner
pub fn new() -> ShardedInterner
Create a new sharded interner with the empty string pre-interned at index 0.
Sourcepub fn intern(&self, s: &str) -> Atom
pub fn intern(&self, s: &str) -> Atom
Intern a string, returning its Atom handle. If the string was already interned, returns the existing Atom.
Sourcepub fn intern_owned(&self, s: String) -> Atom
pub fn intern_owned(&self, s: String) -> Atom
Intern an owned String, avoiding allocation if possible.
Sourcepub fn resolve(&self, atom: Atom) -> Arc<str>
pub fn resolve(&self, atom: Atom) -> Arc<str>
Resolve an Atom back to its string value. Returns empty string if atom is out of bounds (safety for error recovery).
Sourcepub fn try_resolve(&self, atom: Atom) -> Option<Arc<str>>
pub fn try_resolve(&self, atom: Atom) -> Option<Arc<str>>
Try to resolve an Atom, returning None if invalid.
Sourcepub fn intern_common(&self)
pub fn intern_common(&self)
Pre-intern common TypeScript keywords and identifiers. Call this after creating the interner for better cache locality.
Trait Implementations§
Source§impl Default for ShardedInterner
impl Default for ShardedInterner
Source§fn default() -> ShardedInterner
fn default() -> ShardedInterner
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl !Freeze for ShardedInterner
impl RefUnwindSafe for ShardedInterner
impl Send for ShardedInterner
impl Sync for ShardedInterner
impl Unpin for ShardedInterner
impl UnsafeUnpin for ShardedInterner
impl UnwindSafe for ShardedInterner
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more