perf: sandbox reset

This commit is contained in:
cha0s 2024-06-29 12:35:54 -05:00
parent 89c32a2299
commit bb7435e18e

View File

@ -30,7 +30,7 @@ export default class Sandbox {
compile() {
let scope = new Scope();
scope.context = this.$$context;
this.scopes = new WeakMap([[this.ast, scope]]);
this.scopes = new Map([[this.ast, scope]]);
traverse(
this.ast,
(node, verb) => {
@ -250,7 +250,10 @@ export default class Sandbox {
reset() {
this.generator = undefined;
this.compile();
for (const scope of this.scopes.values()) {
scope.context = {};
}
this.scopes.get(this.ast).context = this.$$context;
}
run(ops = 1000) {