buildTreeFromBottom: simplify loop (#17091)

This commit is contained in:
Andy 2017-07-11 09:40:02 -07:00 committed by GitHub
parent 23da0ab501
commit 1408109487

View file

@ -531,16 +531,12 @@ namespace ts.server {
const interiorNode = interiorNodes[i] = new LineNode();
let charCount = 0;
let lineCount = 0;
for (let j = 0; j < lineCollectionCapacity; j++) {
if (nodeIndex >= nodes.length) {
break;
}
const end = Math.min(nodeIndex + lineCollectionCapacity, nodes.length);
for (; nodeIndex < end; nodeIndex++) {
const node = nodes[nodeIndex];
interiorNode.add(node);
charCount += node.charCount();
lineCount += node.lineCount();
nodeIndex++;
}
interiorNode.totalChars = charCount;
interiorNode.totalLines = lineCount;