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/Cargo.toml | 1 + oryxc/src/intern.rs | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'oryxc') diff --git a/oryxc/Cargo.toml b/oryxc/Cargo.toml index cd5dedf..a7ab1e4 100644 --- a/oryxc/Cargo.toml +++ b/oryxc/Cargo.toml @@ -4,6 +4,7 @@ version = "0.1.0" edition = "2024" [dependencies] +boxcar = "0.2.14" clap = { version = "4", features = ["derive"] } crossbeam-deque = "0.8.6" dashmap = "6.1.0" 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