From: Chris Lattner Date: Sat, 21 Mar 2009 06:49:19 +0000 (+0000) Subject: continue dancing around the obvious algorithm issues in PR3810: X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=91058ff73fd3b00275348dd4d49f83501dfc0542;p=clang 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% git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67433 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/DeclarationName.h b/include/clang/AST/DeclarationName.h index d1cd4ebc95..42c1640b56 100644 --- a/include/clang/AST/DeclarationName.h +++ b/include/clang/AST/DeclarationName.h @@ -163,8 +163,18 @@ public: (reinterpret_cast(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(Ptr); return 0; }