Skip to content

Commit 49e71c9

Browse files
committed
[SILGen] Minor improvements to generateEnumCaseBlocks
Noticed by MichaelG while reviewing my changes in the previous commit. No intended functionality change.
1 parent 36eae9d commit 49e71c9

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

lib/SILGen/SILGenPattern.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1710,7 +1710,7 @@ static void generateEnumCaseBlocks(
17101710

17111711
auto enumDecl = sourceType.getEnumOrBoundGenericEnum();
17121712

1713-
llvm::DenseMap<EnumElementDecl*, unsigned> caseToIndex;
1713+
llvm::SmallDenseMap<EnumElementDecl *, unsigned, 16> caseToIndex;
17141714
for (auto &row : rows) {
17151715
EnumElementDecl *formalElt;
17161716
Pattern *subPattern = nullptr;
@@ -1774,12 +1774,10 @@ static void generateEnumCaseBlocks(
17741774
if (canAssumeExhaustive) {
17751775
// Check that Sema didn't let any cases slip through. (This can happen
17761776
// with @_downgrade_exhaustivity_check.)
1777-
for (auto elt : enumDecl->getAllElements()) {
1778-
if (!caseToIndex.count(elt)) {
1779-
canAssumeExhaustive = false;
1780-
break;
1781-
}
1782-
}
1777+
canAssumeExhaustive = llvm::all_of(enumDecl->getAllElements(),
1778+
[&](const EnumElementDecl *elt) {
1779+
return caseToIndex.count(elt);
1780+
});
17831781
}
17841782

17851783
if (!canAssumeExhaustive)

0 commit comments

Comments
 (0)