From: Benjamin Kramer Date: Tue, 10 Oct 2017 07:21:34 +0000 (+0000) Subject: [ASTMatchers] Don't create a copy of a std::set when iterating over it. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d89b5f87c94eef6e83389be238f3473f51649c30;p=clang [ASTMatchers] Don't create a copy of a std::set when iterating over it. This is a bit awkward because lookup returns a copy instead of a reference. No functionality change intended. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@315276 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/ASTMatchers/ASTMatchFinder.cpp b/lib/ASTMatchers/ASTMatchFinder.cpp index 49b15ee685..02aee4b46d 100644 --- a/lib/ASTMatchers/ASTMatchFinder.cpp +++ b/lib/ASTMatchers/ASTMatchFinder.cpp @@ -734,7 +734,10 @@ private: BoundNodesTreeBuilder *Builder) { const Type *const CanonicalType = ActiveASTContext->getCanonicalType(TypeNode); - for (const TypedefNameDecl *Alias : TypeAliases.lookup(CanonicalType)) { + auto Aliases = TypeAliases.find(CanonicalType); + if (Aliases == TypeAliases.end()) + return false; + for (const TypedefNameDecl *Alias : Aliases->second) { BoundNodesTreeBuilder Result(*Builder); if (Matcher.matches(*Alias, this, &Result)) { *Builder = std::move(Result);