Use all_of to simplify control flow. NFC.
authorBenjamin Kramer <benny.kra@googlemail.com>
Sat, 24 Oct 2015 19:30:37 +0000 (19:30 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Sat, 24 Oct 2015 19:30:37 +0000 (19:30 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@251202 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/CodeMetrics.cpp
lib/Analysis/ValueTracking.cpp

index 90fddc539dcb76da08ac817450ec22a4a3bf2fde..4090b4cd752b64113ba10d6ee32f28744d07517c 100644 (file)
@@ -45,14 +45,8 @@ static void completeEphemeralValues(SmallVector<const Value *, 16> &WorkSet,
       continue;
 
     // If all uses of this value are ephemeral, then so is this value.
-    bool FoundNEUse = false;
-    for (const User *I : V->users())
-      if (!EphValues.count(I)) {
-        FoundNEUse = true;
-        break;
-      }
-
-    if (FoundNEUse)
+    if (!std::all_of(V->user_begin(), V->user_end(),
+                     [&](const User *U) { return EphValues.count(U); }))
       continue;
 
     EphValues.insert(V);
index 0fe87176f88b2388b6bc24831b397eeaae2a06a1..bb4220d6164d5d0e2f3e2261ac69b609119c17dc 100644 (file)
@@ -405,14 +405,8 @@ static bool isEphemeralValueOf(Instruction *I, const Value *E) {
       continue;
 
     // If all uses of this value are ephemeral, then so is this value.
-    bool FoundNEUse = false;
-    for (const User *I : V->users())
-      if (!EphValues.count(I)) {
-        FoundNEUse = true;
-        break;
-      }
-
-    if (!FoundNEUse) {
+    if (std::all_of(V->user_begin(), V->user_end(),
+                    [&](const User *U) { return EphValues.count(U); })) {
       if (V == E)
         return true;