diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2012-02-23 15:18:31 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2012-02-23 15:18:31 +0000 |
commit | d0e49e587afd15ccc6c2f910a979f0d3d602d166 (patch) | |
tree | c581425493cd52389153894123b9929bff829e54 /lib/AST/CXXInheritance.cpp | |
parent | a789416a497b2e14e7c2fd721d03e541120bac8d (diff) |
Unique CXXBasePath decls with the SmallVector/pod_sort/std::unique idiom instead of employing a wasteful std::set.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151255 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/CXXInheritance.cpp')
-rw-r--r-- | lib/AST/CXXInheritance.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/AST/CXXInheritance.cpp b/lib/AST/CXXInheritance.cpp index f29bfd1319..f6ce983399 100644 --- a/lib/AST/CXXInheritance.cpp +++ b/lib/AST/CXXInheritance.cpp @@ -23,12 +23,15 @@ using namespace clang; void CXXBasePaths::ComputeDeclsFound() { assert(NumDeclsFound == 0 && !DeclsFound && "Already computed the set of declarations"); - - std::set<NamedDecl *> Decls; - for (CXXBasePaths::paths_iterator Path = begin(), PathEnd = end(); - Path != PathEnd; ++Path) - Decls.insert(*Path->Decls.first); - + + SmallVector<NamedDecl *, 8> Decls; + for (paths_iterator Path = begin(), PathEnd = end(); Path != PathEnd; ++Path) + Decls.push_back(*Path->Decls.first); + + // Eliminate duplicated decls. + llvm::array_pod_sort(Decls.begin(), Decls.end()); + std::unique(Decls.begin(), Decls.end()); + NumDeclsFound = Decls.size(); DeclsFound = new NamedDecl * [NumDeclsFound]; std::copy(Decls.begin(), Decls.end(), DeclsFound); |