From 55e0a19572c4a6c6076f2b7c568364b7c710b78e Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 13 Mar 2005 19:05:05 +0000 Subject: [PATCH] Replace linear search with logrithmic one. llvm-svn: 20580 --- lib/Analysis/DataStructure/DataStructure.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) 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);