Skip to content

Commit

Permalink
[Core] Avoid the special-casing of the first line
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
0x8000-0000 committed Jun 13, 2020
1 parent c7a9cc3 commit a1c3716
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/main/antlr/SamXLexer.g4
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit a1c3716

Please sign in to comment.