use std::cell::RefCell;
use bumpalo::Bump;
#[derive(Default)]
pub struct InternerArena {
vec: RefCell<Vec<*const str>>,
alloc: Bump,
}
unsafe impl Send for InternerArena {}
impl InternerArena {
#[inline]
pub fn push_str(&self, s: &str) -> usize {
let mut v = self.vec.borrow_mut();
let index = v.len();
let s = &*self.alloc.alloc_str(s);
v.push(s as *const str);
index
}
#[inline]
pub fn get(&self, index: usize) -> Option<&str> {
let ptr = *self.vec.borrow().get(index)?;
Some(unsafe { &*ptr })
}
}