pub struct ExprPool { /* private fields */ }Expand description
Arena-like pool for Expr values backed by a hash-consing table.
ExprPool layers GC-root tracking on top of ExprHashcons. Any
expression added via add_root (or subsequently marked with
mark_root) is considered live.
Implementations§
Source§impl ExprPool
impl ExprPool
Sourcepub fn add_root(&mut self, expr: Expr) -> ExprId
pub fn add_root(&mut self, expr: Expr) -> ExprId
Intern an expression and mark it as a GC root.
Sourcepub fn mark_root(&mut self, id: ExprId)
pub fn mark_root(&mut self, id: ExprId)
Mark an existing interned expression as a GC root.
If id is already a root it will appear twice in roots;
live_count uses a deduplicated count so this is harmless.
Sourcepub fn live_count(&self) -> usize
pub fn live_count(&self) -> usize
Return the number of distinct live (root) expressions.
Duplicates in roots are ignored.
Sourcepub fn total_count(&self) -> usize
pub fn total_count(&self) -> usize
Return the total number of distinct expressions in the pool.
Sourcepub fn dedup_ratio(&self) -> f64
pub fn dedup_ratio(&self) -> f64
Compute the deduplication ratio: hits / total intern calls.
A value close to 1.0 means most add/add_root calls were
satisfied from cache.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ExprPool
impl RefUnwindSafe for ExprPool
impl Send for ExprPool
impl Sync for ExprPool
impl Unpin for ExprPool
impl UnsafeUnpin for ExprPool
impl UnwindSafe for ExprPool
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