[cfe-commits] r39317 - /cfe/cfe/trunk/include/clang/Parse/Scope.h
sabre at cs.uiuc.edu
sabre at cs.uiuc.edu
Wed Jul 11 09:43:00 PDT 2007
Author: sabre
Date: Wed Jul 11 11:42:59 2007
New Revision: 39317
URL: http://llvm.org/viewvc/llvm-project?rev=39317&view=rev
Log:
Switch scopes from keeping decls in SmallSet to keeping them in the new
SmallPtrSet data structure. This datastructure handles the 'nonsmall' case
quite gracefully, with an efficient exponentially probed hashtable. This is
important for handling global scope, which gets many thousands of decls (e.g.
every function and enum value). Of course the typical inner scopes are still
as efficient as ever.
On my mac pro, this speeds up parsing carbon.h from 0.59s to 0.168s (3.5x),
and there is still low hanging fruit :).
For reference, GCC on the same system takes 0.33s for -fsyntax-only.
Modified:
cfe/cfe/trunk/include/clang/Parse/Scope.h
Modified: cfe/cfe/trunk/include/clang/Parse/Scope.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/include/clang/Parse/Scope.h?rev=39317&r1=39316&r2=39317&view=diff
==============================================================================
--- cfe/cfe/trunk/include/clang/Parse/Scope.h (original)
+++ cfe/cfe/trunk/include/clang/Parse/Scope.h Wed Jul 11 11:42:59 2007
@@ -15,6 +15,7 @@
#define LLVM_CLANG_PARSE_SCOPE_H
#include "clang/Parse/Action.h"
+#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallSet.h"
namespace llvm {
@@ -77,7 +78,9 @@
/// popped, these declarations are removed from the IdentifierTable's notion
/// of current declaration. It is up to the current Action implementation to
/// implement these semantics.
- SmallSet<Action::DeclTy*, 32> DeclsInScope;
+ typedef SmallPtrSet<Action::DeclTy*, 32> DeclSetTy;
+ //typedef SmallSet<Action::DeclTy*, 32> DeclSetTy;
+ DeclSetTy DeclsInScope;
public:
Scope(Scope *Parent, unsigned ScopeFlags) {
Init(Parent, ScopeFlags);
@@ -100,7 +103,7 @@
}
- typedef SmallSet<Action::DeclTy*, 32>::iterator decl_iterator;
+ typedef DeclSetTy::iterator decl_iterator;
decl_iterator decl_begin() const { return DeclsInScope.begin(); }
decl_iterator decl_end() const { return DeclsInScope.end(); }
More information about the cfe-commits
mailing list