Skip to content

Commit e755c3f

Browse files
Refactored Into 2 Code Paths
Refactored the code so that there is only a single branch for when there is one stored property and the rest return a SILType() as per @simonmpilkington suggestion.
1 parent 06839c4 commit e755c3f

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

lib/IRGen/GenType.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2031,13 +2031,9 @@ SILType irgen::getSingletonAggregateFieldType(IRGenModule &IGM,
20312031

20322032
// If there's only one stored property, we have the layout of its field.
20332033
auto allFields = structDecl->getStoredProperties();
2034-
auto field = allFields.begin();
2035-
// If there are no other fields exit early to prevent calling std::next on
2036-
// an invalid iterator.
2037-
if (allFields.empty())
2038-
return SILType();
20392034

2040-
if (std::next(field) == allFields.end())
2035+
auto field = allFields.begin();
2036+
if (!allFields.empty() && std::next(field) == allFields.end())
20412037
return t.getFieldType(*field, *IGM.SILMod);
20422038

20432039
return SILType();

0 commit comments

Comments
 (0)