summaryrefslogtreecommitdiff
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
parent6531b0855d63424b149ad5f234d1279a2548edc4 (diff)
Use a boxcar in the interner
-rw-r--r--Cargo.lock7
-rw-r--r--oryxc/Cargo.toml1
-rw-r--r--oryxc/src/intern.rs8
3 files changed, 12 insertions, 4 deletions
diff --git a/Cargo.lock b/Cargo.lock
index ee11eb5..b835f73 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -59,6 +59,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "843867be96c8daad0d758b57df9392b6d8d271134fce549de6ce169ff98a92af"
[[package]]
+name = "boxcar"
+version = "0.2.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "36f64beae40a84da1b4b26ff2761a5b895c12adc41dc25aaee1c4f2bbfe97a6e"
+
+[[package]]
name = "cfg-if"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -210,6 +216,7 @@ checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe"
name = "oryxc"
version = "0.1.0"
dependencies = [
+ "boxcar",
"clap",
"crossbeam-deque",
"dashmap",
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;
}
}