From bb7435e18e71beb0ea1c33fbcc4b09a314ba01be Mon Sep 17 00:00:00 2001 From: cha0s Date: Sat, 29 Jun 2024 12:35:54 -0500 Subject: [PATCH] perf: sandbox reset --- app/astride/sandbox.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/astride/sandbox.js b/app/astride/sandbox.js index 59731eb..41a1dc4 100644 --- a/app/astride/sandbox.js +++ b/app/astride/sandbox.js @@ -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) {