web playground: don't include editor.getValue() call in parse time

This commit is contained in:
Max Brunsfeld 2019-08-30 21:06:57 -07:00
parent 69ab405325
commit fd80d60ae8

View file

@ -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;