Skip to content

Commit 12dce85

Browse files
committed
[NFC][ConstraintSystem] Use llvm::count_if for the count methods on
Constraint.
1 parent abfc903 commit 12dce85

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

include/swift/Sema/Constraint.h

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -673,21 +673,15 @@ class Constraint final : public llvm::ilist_node<Constraint>,
673673
}
674674

675675
unsigned countFavoredNestedConstraints() const {
676-
unsigned count = 0;
677-
for (auto *constraint : Nested)
678-
if (constraint->isFavored() && !constraint->isDisabled())
679-
count++;
680-
681-
return count;
676+
return llvm::count_if(Nested, [](const Constraint *constraint) {
677+
return constraint->isFavored() && !constraint->isDisabled();
678+
});
682679
}
683680

684681
unsigned countActiveNestedConstraints() const {
685-
unsigned count = 0;
686-
for (auto *constraint : Nested)
687-
if (!constraint->isDisabled())
688-
count++;
689-
690-
return count;
682+
return llvm::count_if(Nested, [](const Constraint *constraint) {
683+
return !constraint->isDisabled();
684+
});
691685
}
692686

693687
/// Determine if this constraint represents explicit conversion,

0 commit comments

Comments
 (0)