]> granicus.if.org Git - clang/commitdiff
Simplify: don't try to complete the list of decls twice when iterating over the
authorRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 25 Mar 2014 00:27:18 +0000 (00:27 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 25 Mar 2014 00:27:18 +0000 (00:27 +0000)
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

index ce1f1b46bbbb557fc62c790a3732c1ef8afdfc20..d2016af89f1318c209adfcd96081c7c19195c8eb 100644 (file)
@@ -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<DeclContext*>(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<DeclContext*>(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<DeclContext*>(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<DeclContext*>(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<DeclContext*>(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