Use find_if to simplify control flow. NFC.

llvm-svn: 251200
This commit is contained in:
Benjamin Kramer 2015-10-24 19:03:15 +00:00
parent ffd6b3bb29
commit 74b6d3b967
1 changed files with 5 additions and 10 deletions

View File

@ -107,18 +107,13 @@ static const AllocFnsTy *getAllocationData(const Value *V, AllocType AllocTy,
if (!TLI || !TLI->getLibFunc(FnName, TLIFn) || !TLI->has(TLIFn))
return nullptr;
unsigned i = 0;
bool found = false;
for ( ; i < array_lengthof(AllocationFnData); ++i) {
if (AllocationFnData[i].Func == TLIFn) {
found = true;
break;
}
}
if (!found)
const AllocFnsTy *FnData =
std::find_if(std::begin(AllocationFnData), std::end(AllocationFnData),
[TLIFn](const AllocFnsTy &Fn) { return Fn.Func == TLIFn; });
if (FnData == std::end(AllocationFnData))
return nullptr;
const AllocFnsTy *FnData = &AllocationFnData[i];
if ((FnData->AllocTy & AllocTy) != FnData->AllocTy)
return nullptr;