summaryrefslogtreecommitdiff
path: root/oryxc
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2026-03-05 00:39:09 +0100
committerThomas Voss <mail@thomasvoss.com> 2026-03-05 00:39:09 +0100
commit041df318e6b49b350502348dcfc95176077e9f8f (patch)
tree64c25d56cfee54fe25a8a8dda815e8231b2e8660 /oryxc
parent6531b0855d63424b149ad5f234d1279a2548edc4 (diff)
Use a boxcar in the interner
Diffstat (limited to 'oryxc')
-rw-r--r--oryxc/Cargo.toml1
-rw-r--r--oryxc/src/intern.rs8
2 files changed, 5 insertions, 4 deletions
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<UniStr<'a>, 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;
}
}