Is arena usage here reliable?

In my compiler codebase I'm afraid I'm doing something inefficient. I'm structuring the symbolic part of the project and I'm wondering how much impact there will be when you instantiate an Unresolved symbol multiple times: it will stay in the RAM until the compiler finishes running? Or is this a normal thing in compilers written in systems programming languages?

Other than Unresolved, I do also expect that certain symbols are throwaway, like some constant values created temporarily.

use crate::ns::*;
use std::cell::{Cell, RefCell};
use std::rc::Rc;

pub struct SymbolFactory<'a> {
    pub(crate) host: &'a mut SymbolHost,
}

impl<'a> SymbolFactory<'a> {
    pub fn create_unresolved(&self) -> Symbol {
        Symbol(self.host.arena.allocate(SymbolKind::Unresolved(Cell::new(0))))
    }

    ...
}

One thing I think of doing maybe is periodic garbage collection at the arena. Would this help me?

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.