From 9ce3a5342763acaa028fd4eb328f69c9163da1f9 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Mon, 23 Sep 2019 16:55:52 -0700 Subject: [PATCH] Precompute tree edits in playground script --- docs/assets/js/playground.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/assets/js/playground.js b/docs/assets/js/playground.js index 5f337426..686be90d 100644 --- a/docs/assets/js/playground.js +++ b/docs/assets/js/playground.js @@ -104,11 +104,12 @@ let tree; async function handleCodeChange(editor, changes) { const newText = codeEditor.getValue() + '\n'; + const edits = tree && changes && changes.map(treeEditForEditorChange); const start = performance.now(); - if (tree && changes) { - for (const change of changes) { - tree.edit(treeEditForEditorChange(change)); + if (edits) { + for (const edit of edits) { + tree.edit(edit); } } const newTree = parser.parse(newText, tree);