Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ndc_vm/src/value/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub enum Function {

Memoized {
cache: Rc<RefCell<HashMap<u64, Value>>>,
function: Box<Self>,
function: Rc<Self>,
},
}

Expand Down
4 changes: 2 additions & 2 deletions ndc_vm/src/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ impl Vm {
let func = func.clone();
self.stack.push(Value::function(Function::Memoized {
cache: Rc::new(RefCell::new(HashMap::default())),
function: Box::new(func),
function: Rc::new(func),
}));
}
}
Expand Down Expand Up @@ -625,7 +625,7 @@ impl Vm {

// Cache miss: dispatch the inner function and remember to store
// the result in the cache when this frame returns.
self.dispatch_call_with_memo(*function, args, Some((cache, key)))
self.dispatch_call_with_memo(Rc::unwrap_or_clone(function), args, Some((cache, key)))
} else {
self.dispatch_call_with_memo(func, args, None)
}
Expand Down
Loading