//! Arena de asignación por frame: cero basura en el heap durante el render.
use bumpalo::Bump;
pub struct FrameArena {
bump: Bump,
}
impl FrameArena {
pub fn new() -> Self {
Self { bump: Bump::new() }
}
pub fn alloc<T>(&self, value: T) -> &mut T {
self.bump.alloc(value)
}
pub fn alloc_str(&self, text: &str) -> &str {
self.bump.alloc_str(text)
}
/// Se invoca al terminar cada frame; conserva el chunk más grande.
pub fn reset(&mut self) {
self.bump.reset();
}
pub fn allocated_bytes(&self) -> usize {
self.bump.allocated_bytes()
}
}
impl Default for FrameArena {
fn default() -> Self {
Self::new()
}
}