From: Chris Lattner Date: Sun, 13 Mar 2005 19:05:05 +0000 (+0000) Subject: Replace linear search with logrithmic one. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=2787e03d0e22faa8030ca8c05dc2da2bcd44748b;p=oota-llvm.git Replace linear search with logrithmic one. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20580 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Analysis/DataStructure/DataStructure.cpp b/lib/Analysis/DataStructure/DataStructure.cpp index 7679eeb4164..58a0aa577c2 100644 --- a/lib/Analysis/DataStructure/DataStructure.cpp +++ b/lib/Analysis/DataStructure/DataStructure.cpp @@ -443,10 +443,7 @@ bool DSNode::mergeTypeInfo(const Type *NewTy, unsigned Offset, case Type::StructTyID: { const StructType *STy = cast(SubType); const StructLayout &SL = *TD.getStructLayout(STy); - - unsigned i = 0, e = SL.MemberOffsets.size(); - for (; i+1 < e && SL.MemberOffsets[i+1] <= Offset-O; ++i) - /* empty */; + unsigned i = SL.getElementContainingOffset(Offset-O); // The offset we are looking for must be in the i'th element... SubType = STy->getElementType(i);