From 041df318e6b49b350502348dcfc95176077e9f8f Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Thu, 5 Mar 2026 00:39:09 +0100 Subject: Use a boxcar in the interner --- oryxc/src/intern.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'oryxc/src/intern.rs') diff --git a/oryxc/src/intern.rs b/oryxc/src/intern.rs index 5c569b8..96b5fa9 100644 --- a/oryxc/src/intern.rs +++ b/oryxc/src/intern.rs @@ -3,6 +3,7 @@ use std::hash::{ Hasher, }; +use boxcar; use dashmap::DashMap; use unicode_normalization::{ self, @@ -14,7 +15,7 @@ use crate::prelude::*; pub struct Interner<'a> { map: DashMap, SymbolId>, - store: Vec<&'a str>, + store: boxcar::Vec<&'a str>, } #[derive(Debug, Eq)] @@ -63,7 +64,7 @@ impl<'a> Interner<'a> { pub fn new() -> Self { return Interner { map: DashMap::new(), - store: Vec::new(), + store: boxcar::Vec::with_capacity(1024), }; } @@ -75,9 +76,8 @@ impl<'a> Interner<'a> { if let Some(key) = self.map.get(&UniStr(value)) { return *key; } - let key = SymbolId(self.store.len() as u32); + let key = SymbolId(self.store.push(value) as u32); self.map.insert(UniStr(value), key); - self.store.push(value); return key; } } -- cgit v1.2.3