From da995609e6e963eaa77346d43b0a33b81e53a785 Mon Sep 17 00:00:00 2001 From: Gabor Greif Date: Thu, 8 Jul 2010 16:56:18 +0000 Subject: [PATCH] only dereference iterator once in the loop (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 | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/include/llvm/Analysis/DominatorInternals.h b/include/llvm/Analysis/DominatorInternals.h index 8cea96d3560..2febdacc40a 100644 --- a/include/llvm/Analysis/DominatorInternals.h +++ b/include/llvm/Analysis/DominatorInternals.h @@ -265,14 +265,17 @@ void Calculate(DominatorTreeBase::NodeType>& DT, // initialize the semi dominator to point to the parent node WInfo.Semi = WInfo.Parent; - for (typename GraphTraits >::ChildIteratorType CI = - GraphTraits >::child_begin(W), - E = GraphTraits >::child_end(W); CI != E; ++CI) - if (DT.Info.count(*CI)) { // Only if this predecessor is reachable! - unsigned SemiU = DT.Info[Eval(DT, *CI)].Semi; + typedef GraphTraits > 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(DT, N)].Semi; if (SemiU < WInfo.Semi) WInfo.Semi = SemiU; } + } DT.Info[DT.Vertex[WInfo.Semi]].Bucket.push_back(W);