diff options
| author | Thomas Voss <mail@thomasvoss.com> | 2026-03-05 00:39:09 +0100 |
|---|---|---|
| committer | Thomas Voss <mail@thomasvoss.com> | 2026-03-05 00:39:09 +0100 |
| commit | 041df318e6b49b350502348dcfc95176077e9f8f (patch) | |
| tree | 64c25d56cfee54fe25a8a8dda815e8231b2e8660 /oryxc/src | |
| parent | 6531b0855d63424b149ad5f234d1279a2548edc4 (diff) | |
Use a boxcar in the interner
Diffstat (limited to 'oryxc/src')
| -rw-r--r-- | oryxc/src/intern.rs | 8 |
1 files changed, 4 insertions, 4 deletions
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; } } |