From 5294e92d27da2bb2f1aca162fb12bc0cb8646e73 Mon Sep 17 00:00:00 2001 From: Orta Therox Date: Fri, 9 Aug 2019 13:48:07 -0400 Subject: [PATCH] Use switch instead of instatating an array and when looking inside a module --- src/compiler/parser.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 522f4974ddf..b51c90eb742 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -2434,9 +2434,16 @@ namespace ts { const moduleSpecifier = parseOptionalToken(SyntaxKind.ModuleKeyword); if (moduleSpecifier) { const moduleTag = createNode(SyntaxKind.JSDocNamepathType, moduleSpecifier.pos) as JSDocNamepathType; - const terminators = [SyntaxKind.CloseBraceToken, SyntaxKind.EndOfFileToken, SyntaxKind.CommaToken, SyntaxKind.CloseParenToken, SyntaxKind.WhitespaceTrivia]; - while (terminators.indexOf(token()) < 0) { - nextTokenJSDoc(); + terminate: while (true) { + switch (token()) { + case SyntaxKind.CloseBraceToken: + case SyntaxKind.EndOfFileToken: + case SyntaxKind.CommaToken: + case SyntaxKind.WhitespaceTrivia: + break terminate; + default: + nextTokenJSDoc(); + } } scanner.setInJSDocType(false);