From a1c37161ba3952f6d73bca08723c7b61150be2b4 Mon Sep 17 00:00:00 2001 From: Florin Iucha Date: Sat, 13 Jun 2020 00:00:53 -0400 Subject: [PATCH] [Core] Avoid the special-casing of the first line This special case creates a 20x slowdown on the lexing because the function atStartOfInput() which returns true exactly once and false thereafter is invoked for each token. --- src/main/antlr/SamXLexer.g4 | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/antlr/SamXLexer.g4 b/src/main/antlr/SamXLexer.g4 index 579bcc3..2379e28 100644 --- a/src/main/antlr/SamXLexer.g4 +++ b/src/main/antlr/SamXLexer.g4 @@ -188,9 +188,7 @@ SPACES : [ \t]+ -> channel(WHITESPACE) ; COMMENT : '%' ~[\r\n\f]* -> channel(COMMENTS) ; NEWLINE - : ( {atStartOfInput()}? SPACES - | ( '\r'? '\n' | '\r' | '\f' ) SPACES? - ) + : ( '\r'? '\n' | '\r' | '\f' ) SPACES? { if (ignoreNewLinesInConditions) {