Skip to content

Commit 1408109

Browse files
author
Andy
authored
buildTreeFromBottom: simplify loop (microsoft#17091)
1 parent 23da0ab commit 1408109

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/server/scriptVersionCache.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -531,16 +531,12 @@ namespace ts.server {
531531
const interiorNode = interiorNodes[i] = new LineNode();
532532
let charCount = 0;
533533
let lineCount = 0;
534-
for (let j = 0; j < lineCollectionCapacity; j++) {
535-
if (nodeIndex >= nodes.length) {
536-
break;
537-
}
538-
534+
const end = Math.min(nodeIndex + lineCollectionCapacity, nodes.length);
535+
for (; nodeIndex < end; nodeIndex++) {
539536
const node = nodes[nodeIndex];
540537
interiorNode.add(node);
541538
charCount += node.charCount();
542539
lineCount += node.lineCount();
543-
nodeIndex++;
544540
}
545541
interiorNode.totalChars = charCount;
546542
interiorNode.totalLines = lineCount;

0 commit comments

Comments
 (0)