Implemented SymTable optimization for efficient variable updates
This commit is contained in:
parent
dcb2969b0a
commit
381852b3bd
9 changed files with 122 additions and 23 deletions
|
|
@ -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())
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue