Replace linear search with logrithmic one.
authorChris Lattner <sabre@nondot.org>
Sun, 13 Mar 2005 19:05:05 +0000 (19:05 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 13 Mar 2005 19:05:05 +0000 (19:05 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20580 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/DataStructure/DataStructure.cpp

index 7679eeb4164fc439febd525a1dd174478476b7fc..58a0aa577c2082dd84253663c32f36b3d7d02bec 100644 (file)
@@ -443,10 +443,7 @@ bool DSNode::mergeTypeInfo(const Type *NewTy, unsigned Offset,
     case Type::StructTyID: {
       const StructType *STy = cast<StructType>(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);