[llvm] r251200 - Use find_if to simplify control flow. NFC.
Benjamin Kramer via llvm-commits
llvm-commits at lists.llvm.org
Sat Oct 24 12:03:15 PDT 2015
Author: d0k
Date: Sat Oct 24 14:03:15 2015
New Revision: 251200
URL: http://llvm.org/viewvc/llvm-project?rev=251200&view=rev
Log:
Use find_if to simplify control flow. NFC.
Modified:
llvm/trunk/lib/Analysis/MemoryBuiltins.cpp
Modified: llvm/trunk/lib/Analysis/MemoryBuiltins.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/MemoryBuiltins.cpp?rev=251200&r1=251199&r2=251200&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/MemoryBuiltins.cpp (original)
+++ llvm/trunk/lib/Analysis/MemoryBuiltins.cpp Sat Oct 24 14:03:15 2015
@@ -107,18 +107,13 @@ static const AllocFnsTy *getAllocationDa
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;
More information about the llvm-commits
mailing list