diff options
author | Chris Lattner <sabre@nondot.org> | 2009-03-21 06:49:19 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-03-21 06:49:19 +0000 |
commit | 316e1c19dfeeff0f55609471f5b64d32ea3b3ef6 (patch) | |
tree | ce8c98ce1174bf5da96b6bd9b3196294d49de520 /clang | |
parent | 7d5608dd72a10ff1bf2b5bfa26a60f28e1c5eada (diff) | |
download | bcm5719-llvm-316e1c19dfeeff0f55609471f5b64d32ea3b3ef6.tar.gz bcm5719-llvm-316e1c19dfeeff0f55609471f5b64d32ea3b3ef6.zip |
continue dancing around the obvious algorithm issues in PR3810:
This speeds up getAsIdentifierInfo from being a call to a function
with a big switch to a single testl instruction. This speeds up
the example in PR3810 by 6.2%
llvm-svn: 67433
Diffstat (limited to 'clang')
-rw-r--r-- | clang/include/clang/AST/DeclarationName.h | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/clang/include/clang/AST/DeclarationName.h b/clang/include/clang/AST/DeclarationName.h index d1cd4ebc958..42c1640b564 100644 --- a/clang/include/clang/AST/DeclarationName.h +++ b/clang/include/clang/AST/DeclarationName.h @@ -163,8 +163,18 @@ public: (reinterpret_cast<IdentifierInfo *>(Ptr & ~PtrMask)); } + /// Predicate functions for querying what type of name this is. + bool isIdentifier() const { return getStoredNameKind() == StoredIdentifier; } + bool isObjCZeroArgSelector() const { + return getStoredNameKind() == StoredObjCZeroArgSelector; + } + bool isObjCOneArgSelector() const { + return getStoredNameKind() == StoredObjCOneArgSelector; + } + /// getNameKind - Determine what kind of name this is. NameKind getNameKind() const; + /// getName - Retrieve the human-readable string for this name. std::string getAsString() const; @@ -173,7 +183,7 @@ public: /// this declaration name, or NULL if this declaration name isn't a /// simple identifier. IdentifierInfo *getAsIdentifierInfo() const { - if (getNameKind() == Identifier) + if (isIdentifier()) return reinterpret_cast<IdentifierInfo *>(Ptr); return 0; } |