Skip to content

Commit d71b3df

Browse files
committed
small vector sizes
1 parent 8845845 commit d71b3df

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

lib/Sema/DerivedConformanceComparable.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ deriveBodyComparable_enum_noAssociatedValues_lt(AbstractFunctionDecl *ltDecl,
6464
auto enumDecl = cast<EnumDecl>(aParam->getType()->getAnyNominal());
6565

6666
// Generate the conversion from the enums to integer indices.
67-
SmallVector<ASTNode, 6> statements;
67+
SmallVector<ASTNode, 8> statements;
6868
DeclRefExpr *aIndex = DerivedConformance::convertEnumToIndex(statements, parentDC, enumDecl,
6969
aParam, ltDecl, "index_a");
7070
DeclRefExpr *bIndex = DerivedConformance::convertEnumToIndex(statements, parentDC, enumDecl,
@@ -123,7 +123,7 @@ deriveBodyComparable_enum_hasAssociatedValues_lt(AbstractFunctionDecl *ltDecl, v
123123
Type enumType = aParam->getType();
124124
auto enumDecl = cast<EnumDecl>(aParam->getType()->getAnyNominal());
125125

126-
SmallVector<ASTNode, 6> statements;
126+
SmallVector<ASTNode, 8> statements;
127127
SmallVector<ASTNode, 4> cases;
128128
unsigned elementCount = 0; // need this as `getAllElements` returns a generator
129129

@@ -134,7 +134,7 @@ deriveBodyComparable_enum_hasAssociatedValues_lt(AbstractFunctionDecl *ltDecl, v
134134
elementCount++;
135135

136136
// .<elt>(let l0, let l1, ...)
137-
SmallVector<VarDecl*, 3> lhsPayloadVars;
137+
SmallVector<VarDecl*, 4> lhsPayloadVars;
138138
auto lhsSubpattern = DerivedConformance::enumElementPayloadSubpattern(elt, 'l', ltDecl,
139139
lhsPayloadVars);
140140
auto lhsElemPat = new (C) EnumElementPattern(TypeLoc::withoutLoc(enumType),
@@ -144,7 +144,7 @@ deriveBodyComparable_enum_hasAssociatedValues_lt(AbstractFunctionDecl *ltDecl, v
144144
lhsElemPat->setImplicit();
145145

146146
// .<elt>(let r0, let r1, ...)
147-
SmallVector<VarDecl*, 3> rhsPayloadVars;
147+
SmallVector<VarDecl*, 4> rhsPayloadVars;
148148
auto rhsSubpattern = DerivedConformance::enumElementPayloadSubpattern(elt, 'r', ltDecl,
149149
rhsPayloadVars);
150150
auto rhsElemPat = new (C) EnumElementPattern(TypeLoc::withoutLoc(enumType),
@@ -182,7 +182,7 @@ deriveBodyComparable_enum_hasAssociatedValues_lt(AbstractFunctionDecl *ltDecl, v
182182
// Generate a guard statement for each associated value in the payload,
183183
// breaking out early if any pair is unequal. (same as Equatable synthesis.)
184184
// the else statement performs the lexicographic comparison.
185-
SmallVector<ASTNode, 6> statementsInCase;
185+
SmallVector<ASTNode, 8> statementsInCase;
186186
for (size_t varIdx = 0; varIdx < lhsPayloadVars.size(); varIdx++) {
187187
auto lhsVar = lhsPayloadVars[varIdx];
188188
auto lhsExpr = new (C) DeclRefExpr(lhsVar, DeclNameLoc(),

lib/Sema/DerivedConformances.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -554,10 +554,10 @@ DeclRefExpr *DerivedConformance::convertEnumToIndex(SmallVectorImpl<ASTNode> &st
554554
/// \p theEnum The enum whose elements and associated values should be checked.
555555
/// \p protocol The protocol being requested.
556556
/// \return The ParamDecl of each associated value whose type does not conform.
557-
SmallVector<ParamDecl *, 3>
557+
SmallVector<ParamDecl *, 4>
558558
DerivedConformance::associatedValuesNotConformingToProtocol(DeclContext *DC, EnumDecl *theEnum,
559559
ProtocolDecl *protocol) {
560-
SmallVector<ParamDecl *, 3> nonconformingAssociatedValues;
560+
SmallVector<ParamDecl *, 4> nonconformingAssociatedValues;
561561
for (auto elt : theEnum->getAllElements()) {
562562
auto PL = elt->getParameterList();
563563
if (!PL)
@@ -610,7 +610,7 @@ DerivedConformance::enumElementPayloadSubpattern(EnumElementDecl *enumElementDec
610610
// types, and labels. For example:
611611
// case a(x: Int) => (x: let a0)
612612
// case b(Int, String) => (let a0, let a1)
613-
SmallVector<TuplePatternElt, 3> elementPatterns;
613+
SmallVector<TuplePatternElt, 4> elementPatterns;
614614
int index = 0;
615615
for (auto tupleElement : tupleType->getElements()) {
616616
auto payloadVar = indexedVarDecl(varPrefix, index++,

lib/Sema/DerivedConformances.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ class DerivedConformance {
256256
/// associated values should be checked. \p protocol The protocol being
257257
/// requested. \return The ParamDecl of each associated value whose type does
258258
/// not conform.
259-
static SmallVector<ParamDecl *, 3>
259+
static SmallVector<ParamDecl *, 4>
260260
associatedValuesNotConformingToProtocol(DeclContext *DC, EnumDecl *theEnum,
261261
ProtocolDecl *protocol);
262262

0 commit comments

Comments
 (0)