[cfe-commits] r67430 - in /cfe/trunk: include/clang/AST/DeclBase.h lib/AST/DeclBase.cpp
Chris Lattner
sabre at nondot.org
Fri Mar 20 23:27:32 PDT 2009
Author: lattner
Date: Sat Mar 21 01:27:31 2009
New Revision: 67430
URL: http://llvm.org/viewvc/llvm-project?rev=67430&view=rev
Log:
partially inline getAttrs() to speed up PR3810 (and lots of
other code presumably) by 4.3%
Modified:
cfe/trunk/include/clang/AST/DeclBase.h
cfe/trunk/lib/AST/DeclBase.cpp
Modified: cfe/trunk/include/clang/AST/DeclBase.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=67430&r1=67429&r2=67430&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclBase.h (original)
+++ cfe/trunk/include/clang/AST/DeclBase.h Sat Mar 21 01:27:31 2009
@@ -180,7 +180,10 @@
bool hasAttrs() const { return HasAttrs; }
void addAttr(Attr *attr);
- const Attr *getAttrs() const;
+ const Attr *getAttrs() const {
+ if (!HasAttrs) return 0; // common case, no attributes.
+ return getAttrsImpl(); // Uncommon case, out of line hash lookup.
+ }
void swapAttrs(Decl *D);
void invalidateAttrs();
@@ -188,7 +191,6 @@
for (const Attr *attr = getAttrs(); attr; attr = attr->getNext())
if (const T *V = dyn_cast<T>(attr))
return V;
-
return 0;
}
@@ -326,6 +328,9 @@
// FIXME: This will eventually be a pure virtual function.
assert (false && "Not implemented.");
}
+private:
+ const Attr *getAttrsImpl() const;
+
};
/// PrettyStackTraceDecl - If a crash occurs, indicate that it happened when
Modified: cfe/trunk/lib/AST/DeclBase.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=67430&r1=67429&r2=67430&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclBase.cpp (original)
+++ cfe/trunk/lib/AST/DeclBase.cpp Sat Mar 21 01:27:31 2009
@@ -171,10 +171,8 @@
}
}
-const Attr *Decl::getAttrs() const {
- if (!HasAttrs)
- return 0;
-
+const Attr *Decl::getAttrsImpl() const {
+ assert(HasAttrs && "getAttrs() should verify this!");
return (*DeclAttrs)[this];
}
More information about the cfe-commits
mailing list