Implemented SymTable optimization for efficient variable updates

This commit is contained in:
Ava Apples Affine 2023-03-20 17:16:44 -07:00
parent dcb2969b0a
commit 381852b3bd
Signed by: affine
GPG key ID: 3A4645B8CF806069
9 changed files with 122 additions and 23 deletions

View file

@ -202,22 +202,10 @@ pub fn let_callback(ast: &Seg, syms: &mut SymTable) -> Result<Ctr, String> {
return Err("evaluation failure".to_string());
}
// we need to get any var declared from within the let eval forms
// those need to exist in the outside context
// TODO: make this more optimal
// How can we skip iterations?
// implement a counter for number of calls to def
// store it inside the SymTable and Symbol
// only re-insert into global scope what is most recent
for i in localsyms.iter() {
if !locals.contains(i.0) {
syms.insert(
i.0.clone(),
i.1.clone(),
);
}
for i in locals {
localsyms.remove(&i);
}
syms.update(&mut localsyms);
Ok((*result).clone())
}