From 9bb66bd6f5a67b5e50ee1b7d8d77ab44026db5d9 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Sun, 3 Jan 2016 07:33:36 +0000 Subject: [PATCH] [TableGen] Use std::find_if and a lambda instead of manual loops. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256698 91177308-0d34-0410-b5e6-96231b3b80d8 --- utils/TableGen/AsmMatcherEmitter.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/utils/TableGen/AsmMatcherEmitter.cpp b/utils/TableGen/AsmMatcherEmitter.cpp index 2ec65442a33..9a4390753c2 100644 --- a/utils/TableGen/AsmMatcherEmitter.cpp +++ b/utils/TableGen/AsmMatcherEmitter.cpp @@ -503,20 +503,21 @@ struct MatchableInfo { /// findAsmOperand - Find the AsmOperand with the specified name and /// suboperand index. int findAsmOperand(StringRef N, int SubOpIdx) const { - for (unsigned i = 0, e = AsmOperands.size(); i != e; ++i) - if (N == AsmOperands[i].SrcOpName && - SubOpIdx == AsmOperands[i].SubOpIdx) - return i; - return -1; + auto I = std::find_if(AsmOperands.begin(), AsmOperands.end(), + [&](const AsmOperand &Op) { + return Op.SrcOpName == N && Op.SubOpIdx == SubOpIdx; + }); + return (I != AsmOperands.end()) ? I - AsmOperands.begin() : -1; } /// findAsmOperandNamed - Find the first AsmOperand with the specified name. /// This does not check the suboperand index. int findAsmOperandNamed(StringRef N) const { - for (unsigned i = 0, e = AsmOperands.size(); i != e; ++i) - if (N == AsmOperands[i].SrcOpName) - return i; - return -1; + auto I = std::find_if(AsmOperands.begin(), AsmOperands.end(), + [&](const AsmOperand &Op) { + return Op.SrcOpName == N; + }); + return (I != AsmOperands.end()) ? I - AsmOperands.begin() : -1; } void buildInstructionResultOperands(); -- 2.34.1