Avoid the cost of reading node.children when we don't need to

This commit is contained in:
Andrew Dupont 2024-04-21 18:04:01 -07:00
parent 5472e32e21
commit 5ea9adf13b

View File

@ -4501,7 +4501,7 @@ class NodeRangeSet {
getNodeSpec(node, getChildren) {
let { startIndex, endIndex, startPosition, endPosition, id } = node;
let result = { startIndex, endIndex, startPosition, endPosition, id };
if (node.children && getChildren) {
if (getChildren && node.childCount > 0) {
result.children = [];
for (let child of node.children) {
result.children.push(this.getNodeSpec(child, false));