summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaLookup.cpp
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2015-03-13 16:10:42 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2015-03-13 16:10:42 +0000
commit1553727ed377d593f54ffbe464de81b386034f5f (patch)
tree975c291501b36dd87b5b419c8de1a402faa899c3 /clang/lib/Sema/SemaLookup.cpp
parentf11625d131f90ec605773040f797d3b1596b1f01 (diff)
downloadbcm5719-llvm-1553727ed377d593f54ffbe464de81b386034f5f.tar.gz
bcm5719-llvm-1553727ed377d593f54ffbe464de81b386034f5f.zip
Sema: Replace the SetVector/DenseMap/std::sort combination with a simple std::map
This guarantees the order and doesn't increase malloc counts a lot as there are typically very few elements int the map. Provide a little iterator adapter to keep the same interface as we had with the flat sorted list. No functional change intended. llvm-svn: 232173
Diffstat (limited to 'clang/lib/Sema/SemaLookup.cpp')
-rw-r--r--clang/lib/Sema/SemaLookup.cpp22
1 files changed, 1 insertions, 21 deletions
diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp
index d9ac445a6a1..e15e532be19 100644
--- a/clang/lib/Sema/SemaLookup.cpp
+++ b/clang/lib/Sema/SemaLookup.cpp
@@ -3685,8 +3685,7 @@ void TypoCorrectionConsumer::performQualifiedLookups() {
TypoCorrectionConsumer::NamespaceSpecifierSet::NamespaceSpecifierSet(
ASTContext &Context, DeclContext *CurContext, CXXScopeSpec *CurScopeSpec)
- : Context(Context), CurContextChain(buildContextChain(CurContext)),
- isSorted(false) {
+ : Context(Context), CurContextChain(buildContextChain(CurContext)) {
if (NestedNameSpecifier *NNS =
CurScopeSpec ? CurScopeSpec->getScopeRep() : nullptr) {
llvm::raw_string_ostream SpecifierOStream(CurNameSpecifier);
@@ -3705,7 +3704,6 @@ TypoCorrectionConsumer::NamespaceSpecifierSet::NamespaceSpecifierSet(
}
// Add the global context as a NestedNameSpecifier
- Distances.insert(1);
SpecifierInfo SI = {cast<DeclContext>(Context.getTranslationUnitDecl()),
NestedNameSpecifier::GlobalSpecifier(Context), 1};
DistanceMap[1].push_back(SI);
@@ -3725,22 +3723,6 @@ auto TypoCorrectionConsumer::NamespaceSpecifierSet::buildContextChain(
return Chain;
}
-void TypoCorrectionConsumer::NamespaceSpecifierSet::sortNamespaces() {
- SmallVector<unsigned, 4> sortedDistances;
- sortedDistances.append(Distances.begin(), Distances.end());
-
- if (sortedDistances.size() > 1)
- std::sort(sortedDistances.begin(), sortedDistances.end());
-
- Specifiers.clear();
- for (auto D : sortedDistances) {
- SpecifierInfoList &SpecList = DistanceMap[D];
- Specifiers.append(SpecList.begin(), SpecList.end());
- }
-
- isSorted = true;
-}
-
unsigned
TypoCorrectionConsumer::NamespaceSpecifierSet::buildNestedNameSpecifier(
DeclContextList &DeclChain, NestedNameSpecifier *&NNS) {
@@ -3821,8 +3803,6 @@ void TypoCorrectionConsumer::NamespaceSpecifierSet::addNameSpecifier(
llvm::makeArrayRef(NewNameSpecifierIdentifiers));
}
- isSorted = false;
- Distances.insert(NumSpecifiers);
SpecifierInfo SI = {Ctx, NNS, NumSpecifiers};
DistanceMap[NumSpecifiers].push_back(SI);
}
OpenPOWER on IntegriCloud