From 8cd84a8f322a40a69fed9629c810cabd554cf154 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Tue, 25 Mar 2014 00:27:18 +0000 Subject: [PATCH] Simplify: don't try to complete the list of decls twice when iterating over the lookups for a DeclContext. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@204691 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/AST/DeclLookups.h | 36 ++++++++++++++------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/include/clang/AST/DeclLookups.h b/include/clang/AST/DeclLookups.h index ce1f1b46bb..d2016af89f 100644 --- a/include/clang/AST/DeclLookups.h +++ b/include/clang/AST/DeclLookups.h @@ -69,45 +69,39 @@ public: }; inline DeclContext::lookups_range DeclContext::lookups() const { - return lookups_range(lookups_begin(), lookups_end()); -} - -inline DeclContext::all_lookups_iterator DeclContext::lookups_begin() const { DeclContext *Primary = const_cast(this)->getPrimaryContext(); if (Primary->hasExternalVisibleStorage()) getParentASTContext().getExternalSource()->completeVisibleDeclsMap(Primary); if (StoredDeclsMap *Map = Primary->buildLookup()) - return all_lookups_iterator(Map->begin(), Map->end()); - return all_lookups_iterator(); + return lookups_range(all_lookups_iterator(Map->begin(), Map->end()), + all_lookups_iterator(Map->end(), Map->end())); + return lookups_range(); +} + +inline DeclContext::all_lookups_iterator DeclContext::lookups_begin() const { + return lookups().begin(); } inline DeclContext::all_lookups_iterator DeclContext::lookups_end() const { - DeclContext *Primary = const_cast(this)->getPrimaryContext(); - if (Primary->hasExternalVisibleStorage()) - getParentASTContext().getExternalSource()->completeVisibleDeclsMap(Primary); - if (StoredDeclsMap *Map = Primary->buildLookup()) - return all_lookups_iterator(Map->end(), Map->end()); - return all_lookups_iterator(); + return lookups().end(); } inline DeclContext::lookups_range DeclContext::noload_lookups() const { - return lookups_range(noload_lookups_begin(), noload_lookups_end()); + DeclContext *Primary = const_cast(this)->getPrimaryContext(); + if (StoredDeclsMap *Map = Primary->getLookupPtr()) + return lookups_range(all_lookups_iterator(Map->begin(), Map->end()), + all_lookups_iterator(Map->end(), Map->end())); + return lookups_range(); } inline DeclContext::all_lookups_iterator DeclContext::noload_lookups_begin() const { - DeclContext *Primary = const_cast(this)->getPrimaryContext(); - if (StoredDeclsMap *Map = Primary->getLookupPtr()) - return all_lookups_iterator(Map->begin(), Map->end()); - return all_lookups_iterator(); + return noload_lookups().begin(); } inline DeclContext::all_lookups_iterator DeclContext::noload_lookups_end() const { - DeclContext *Primary = const_cast(this)->getPrimaryContext(); - if (StoredDeclsMap *Map = Primary->getLookupPtr()) - return all_lookups_iterator(Map->end(), Map->end()); - return all_lookups_iterator(); + return noload_lookups().end(); } } // end namespace clang -- 2.40.0