Skip to content

Commit fc41f63

Browse files
committed
[PHITransAddr] Use std::find instead of std::count
There is no need to visit all the elements if we are merely performing a membership check. NFCI. llvm-svn: 238701
1 parent a4d2247 commit fc41f63

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

llvm/lib/Analysis/PHITransAddr.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ Value *PHITransAddr::PHITranslateSubExpr(Value *V, BasicBlock *CurBB,
150150
if (!Inst) return V;
151151

152152
// Determine whether 'Inst' is an input to our PHI translatable expression.
153-
bool isInput = std::count(InstInputs.begin(), InstInputs.end(), Inst);
153+
bool isInput =
154+
std::find(InstInputs.begin(), InstInputs.end(), Inst) != InstInputs.end();
154155

155156
// Handle inputs instructions if needed.
156157
if (isInput) {
@@ -276,7 +277,8 @@ Value *PHITransAddr::PHITranslateSubExpr(Value *V, BasicBlock *CurBB,
276277
isNSW = isNUW = false;
277278

278279
// If the old 'LHS' was an input, add the new 'LHS' as an input.
279-
if (std::count(InstInputs.begin(), InstInputs.end(), BOp)) {
280+
if (std::find(InstInputs.begin(), InstInputs.end(), BOp) !=
281+
InstInputs.end()) {
280282
RemoveInstInputs(BOp, InstInputs);
281283
AddAsInput(LHS);
282284
}

0 commit comments

Comments
 (0)