[llvm] r196622 - Cache AllowAtInIdentifier as class variable in AsmLexer
David Peixotto
dpeixott at codeaurora.org
Fri Dec 6 15:05:33 PST 2013
Author: dpeixott
Date: Fri Dec 6 17:05:33 2013
New Revision: 196622
URL: http://llvm.org/viewvc/llvm-project?rev=196622&view=rev
Log:
Cache AllowAtInIdentifier as class variable in AsmLexer
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.
Modified:
llvm/trunk/include/llvm/MC/MCParser/AsmLexer.h
llvm/trunk/lib/MC/MCParser/AsmLexer.cpp
Modified: llvm/trunk/include/llvm/MC/MCParser/AsmLexer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCParser/AsmLexer.h?rev=196622&r1=196621&r2=196622&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCParser/AsmLexer.h (original)
+++ llvm/trunk/include/llvm/MC/MCParser/AsmLexer.h Fri Dec 6 17:05:33 2013
@@ -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;
Modified: llvm/trunk/lib/MC/MCParser/AsmLexer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/AsmLexer.cpp?rev=196622&r1=196621&r2=196622&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/AsmLexer.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/AsmLexer.cpp Fri Dec 6 17:05:33 2013
@@ -25,6 +25,7 @@ AsmLexer::AsmLexer(const MCAsmInfo &_MAI
CurBuf = NULL;
CurPtr = NULL;
isAtStartOfLine = true;
+ AllowAtInIdentifier = !StringRef(MAI.getCommentString()).startswith("@");
}
AsmLexer::~AsmLexer() {
@@ -144,7 +145,6 @@ static bool IsIdentifierChar(char c, boo
(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.
More information about the llvm-commits
mailing list