Skip to content

Commit b83c37a

Browse files
Tiny perf tweaks to scanning.
1 parent 3825cfc commit b83c37a

1 file changed

Lines changed: 14 additions & 9 deletions

File tree

src/services/syntax/scanner.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -613,26 +613,31 @@ module TypeScript.Scanner {
613613
return createTrivia(SyntaxKind.MultiLineCommentTrivia, absoluteStartIndex);
614614
}
615615

616-
function skipMultiLineCommentTrivia(): number {
616+
function skipMultiLineCommentTrivia(): void {
617617
// The '2' is for the "/*" we consumed.
618+
var _index = index + 2;
619+
var _end = end;
620+
618621
index += 2;
619622

620623
while (true) {
621-
if (index === end) {
624+
if (_index === _end) {
622625
reportDiagnostic(end, 0, DiagnosticCode._0_expected, ["*/"]);
623-
return;
626+
break;
624627
}
625628

626-
if ((index + 1) < end &&
627-
str.charCodeAt(index) === CharacterCodes.asterisk &&
628-
str.charCodeAt(index + 1) === CharacterCodes.slash) {
629+
if ((_index + 1) < _end &&
630+
str.charCodeAt(_index) === CharacterCodes.asterisk &&
631+
str.charCodeAt(_index + 1) === CharacterCodes.slash) {
629632

630-
index += 2;
631-
return;
633+
_index += 2;
634+
break;
632635
}
633636

634-
index++;
637+
_index++;
635638
}
639+
640+
index = _index;
636641
}
637642

638643
function scanLineTerminatorSequenceTrivia(ch: number): ISyntaxTrivia {

0 commit comments

Comments
 (0)