[cfe-commits] r47191 - in /cfe/trunk: AST/Decl.cpp include/clang/AST/Attr.h include/clang/AST/Decl.h
Chris Lattner
clattner at apple.com
Fri Feb 15 16:33:12 PST 2008
> URL: http://llvm.org/viewvc/llvm-project?rev=47191&view=rev
> Log:
> Store attributes in a global hash map instead.
Nice! Everyone loves smaller decls. :)
> // Out-of-line virtual method providing a home for Decl.
> Decl::~Decl() {
> + if (!DeclAttrs)
> + return;
> +
> + DeclAttrMapTy::iterator it = DeclAttrs->find(this);
> + if (it != DeclAttrs->end()) {
This should avoid the lookup if HasAttrs is false.
> + if (!DeclAttrs)
> + DeclAttrs = new llvm::DenseMap<const Decl*, Attr*>;
> +
> + Attr *&attr = DeclAttrs->FindAndConstruct(this).second;
This could just be: Attr *&attr = (*DeclAttrs)[this];
>
> +const Attr *Decl::getAttrs() const
> +{
> + if (!HasAttrs || !DeclAttrs)
> + return 0;
I don't think DeclAttrs can be null if HasAttrs is true. i'd just
change this to "if (!HasAttrs) return".
> + return DeclAttrs->find(this)->second;
You can use return (*DeclAttrs)[this] because you know it has an entry
in the table.
Very nice Anders!
-Chris
More information about the cfe-commits
mailing list