[llvm] r256698 - [TableGen] Use std::find_if and a lambda instead of manual loops.
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Sat Jan 2 23:33:37 PST 2016
Author: ctopper
Date: Sun Jan 3 01:33:36 2016
New Revision: 256698
URL: http://llvm.org/viewvc/llvm-project?rev=256698&view=rev
Log:
[TableGen] Use std::find_if and a lambda instead of manual loops.
Modified:
llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp
Modified: llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp?rev=256698&r1=256697&r2=256698&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp Sun Jan 3 01:33:36 2016
@@ -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();
More information about the llvm-commits
mailing list