Skip to content

Commit 1e7fba7

Browse files
shahzadloneCodaFi
authored andcommitted
Reserve a vector where we know the size. (#22077)
* Reserve a vector where we know the size. * Made a temp. to save the cost of calling NTD->getAllProtocols() twice.
1 parent e9c05b0 commit 1e7fba7

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

tools/swift-ide-test/ModuleAPIDiff.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -769,8 +769,10 @@ class SMAModelGenerator : public DeclVisitor<SMAModelGenerator> {
769769
}
770770

771771
std::vector<sma::TypeName> collectProtocolConformances(NominalTypeDecl *NTD) {
772+
const auto AllProtocols = NTD->getAllProtocols();
772773
std::vector<sma::TypeName> Result;
773-
for (const auto *PD : NTD->getAllProtocols()) {
774+
Result.reserve(AllProtocols.size());
775+
for (const auto *PD : AllProtocols) {
774776
Result.emplace_back(convertToTypeName(PD->getDeclaredType()));
775777
}
776778
return Result;

0 commit comments

Comments
 (0)