only dereference iterator once in the loop
authorGabor Greif <ggreif@gmail.com>
Thu, 8 Jul 2010 16:56:18 +0000 (16:56 +0000)
committerGabor Greif <ggreif@gmail.com>
Thu, 8 Jul 2010 16:56:18 +0000 (16:56 +0000)
(by caching the result we save a potentially expensive dereference)

also use typedefs to shorten type declarations

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107883 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Analysis/DominatorInternals.h

index 8cea96d35609316f918db07512169d1dafb4047a..2febdacc40a528a8eeb365f713016ab6efd176f5 100644 (file)
@@ -265,14 +265,17 @@ void Calculate(DominatorTreeBase<typename GraphTraits<NodeT>::NodeType>& DT,
 
     // initialize the semi dominator to point to the parent node
     WInfo.Semi = WInfo.Parent;
-    for (typename GraphTraits<Inverse<NodeT> >::ChildIteratorType CI =
-         GraphTraits<Inverse<NodeT> >::child_begin(W),
-         E = GraphTraits<Inverse<NodeT> >::child_end(W); CI != E; ++CI)
-      if (DT.Info.count(*CI)) {  // Only if this predecessor is reachable!
-        unsigned SemiU = DT.Info[Eval<GraphT>(DT, *CI)].Semi;
+    typedef GraphTraits<Inverse<NodeT> > InvTraits;
+    for (typename InvTraits::ChildIteratorType CI =
+         InvTraits::child_begin(W),
+         E = InvTraits::child_end(W); CI != E; ++CI) {
+      typename InvTraits::NodeType *N = *CI;
+      if (DT.Info.count(N)) {  // Only if this predecessor is reachable!
+        unsigned SemiU = DT.Info[Eval<GraphT>(DT, N)].Semi;
         if (SemiU < WInfo.Semi)
           WInfo.Semi = SemiU;
       }
+    }
 
     DT.Info[DT.Vertex[WInfo.Semi]].Bucket.push_back(W);