Cache AllowAtInIdentifier as class variable in AsmLexer
authorDavid Peixotto <dpeixott@codeaurora.org>
Fri, 6 Dec 2013 23:05:33 +0000 (23:05 +0000)
committerDavid Peixotto <dpeixott@codeaurora.org>
Fri, 6 Dec 2013 23:05:33 +0000 (23:05 +0000)
This commit caches the value of the AllowAtInIdentifier variable as
a class variable in AsmLexer. We do this to avoid repeated MAI
queries and string comparisons each time we lex an identifier.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@196622 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/MC/MCParser/AsmLexer.h
lib/MC/MCParser/AsmLexer.cpp

index 1b3ab577519ba43d10d5505584bb0f121e1268b0..a97b450a46d87acf480698e33508cbf54760d472 100644 (file)
@@ -30,6 +30,7 @@ class AsmLexer : public MCAsmLexer {
   const char *CurPtr;
   const MemoryBuffer *CurBuf;
   bool isAtStartOfLine;
+  bool AllowAtInIdentifier; // Cached here to avoid repeated MAI query.
 
   void operator=(const AsmLexer&) LLVM_DELETED_FUNCTION;
   AsmLexer(const AsmLexer&) LLVM_DELETED_FUNCTION;
index a066e648303309e3926fbe8a35fe027324f8648e..ed98f93758e8918d6603a820c506969656c283b9 100644 (file)
@@ -25,6 +25,7 @@ AsmLexer::AsmLexer(const MCAsmInfo &_MAI) : MAI(_MAI)  {
   CurBuf = NULL;
   CurPtr = NULL;
   isAtStartOfLine = true;
+  AllowAtInIdentifier = !StringRef(MAI.getCommentString()).startswith("@");
 }
 
 AsmLexer::~AsmLexer() {
@@ -144,7 +145,6 @@ static bool IsIdentifierChar(char c, bool AllowAt) {
          (c == '@' && AllowAt) || c == '?';
 }
 AsmToken AsmLexer::LexIdentifier() {
-  bool AllowAtInIdentifier = !StringRef(MAI.getCommentString()).startswith("@");
   // Check for floating point literals.
   if (CurPtr[-1] == '.' && isdigit(*CurPtr)) {
     // Disambiguate a .1243foo identifier from a floating literal.