From fd80d60ae8d9be97bdbe368f2e40bbf25c35415f Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 30 Aug 2019 21:06:57 -0700 Subject: [PATCH] web playground: don't include editor.getValue() call in parse time --- docs/assets/js/playground.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/docs/assets/js/playground.js b/docs/assets/js/playground.js index 4d02c2ea..1b151e42 100644 --- a/docs/assets/js/playground.js +++ b/docs/assets/js/playground.js @@ -65,18 +65,17 @@ let tree; } async function handleCodeChange(editor, changes) { - let start; + const newText = codeEditor.getValue() + '\n'; + + const start = performance.now(); if (tree && changes) { - start = performance.now(); for (const change of changes) { - const edit = treeEditForEditorChange(change); - tree.edit(edit); + tree.edit(treeEditForEditorChange(change)); } - } else { - start = performance.now(); } - const newTree = parser.parse(codeEditor.getValue() + '\n', tree); + const newTree = parser.parse(newText, tree); const duration = (performance.now() - start).toFixed(1); + updateTimeSpan.innerText = `${duration} ms`; if (tree) tree.delete(); tree = newTree;