From 2c987c32ffee90827faa69f4cf2f01478c9f617a Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 8 Apr 2020 10:40:50 -0700 Subject: [PATCH] Fix a super subtle bug: we were strlen'ing the entire buffer every time we returned an lp_ keyword, which is N^2 work with a very large N (particularly when your testcase is half a megabyte of .fir)! This speeds up the parser from 12.75s -> 0.09s (!!!), which feels better to me :) --- lib/Dialect/FIRRTL/FIRToMLIR/FIRLexer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Dialect/FIRRTL/FIRToMLIR/FIRLexer.cpp b/lib/Dialect/FIRRTL/FIRToMLIR/FIRLexer.cpp index 3f1d13f5e70d..25343173d8ba 100644 --- a/lib/Dialect/FIRRTL/FIRToMLIR/FIRLexer.cpp +++ b/lib/Dialect/FIRRTL/FIRToMLIR/FIRLexer.cpp @@ -246,7 +246,7 @@ FIRToken FIRLexer::lexIdentifierOrKeyword(const char *tokStart) { .Default(FIRToken::identifier); if (kind != FIRToken::identifier) { ++curPtr; - return FIRToken(kind, tokStart); + return formToken(kind, tokStart); } }