@@ -3258,6 +3258,18 @@ class Serializer::DeclSerializer : public DeclVisitor<DeclSerializer> {
32583258 }
32593259 }
32603260
3261+ size_t addConformances (const IterableDeclContext *declContext,
3262+ ConformanceLookupKind lookupKind,
3263+ SmallVectorImpl<TypeID> &data) {
3264+ size_t count = 0 ;
3265+ for (auto conformance : declContext->getLocalConformances (lookupKind)) {
3266+ data.push_back (S.addConformanceRef (conformance));
3267+ count++;
3268+ }
3269+
3270+ return count;
3271+ }
3272+
32613273public:
32623274 // / Determine if \p decl is safe to deserialize when it's public
32633275 // / or otherwise needed by the client in normal builds, this should usually
@@ -3785,8 +3797,8 @@ class Serializer::DeclSerializer : public DeclVisitor<DeclSerializer> {
37853797 // / Add all of the inherited entries to the result vector.
37863798 // /
37873799 // / \returns the number of entries added.
3788- unsigned addInherited (ArrayRef<InheritedEntry> inheritedEntries,
3789- SmallVectorImpl<TypeID> &result) {
3800+ size_t addInherited (ArrayRef<InheritedEntry> inheritedEntries,
3801+ SmallVectorImpl<TypeID> &result) {
37903802 for (const auto &inherited : inheritedEntries) {
37913803 assert (!inherited.getType () || !inherited.getType ()->hasArchetype ());
37923804 TypeID typeRef = S.addTypeRef (inherited.getType ());
@@ -3819,13 +3831,9 @@ class Serializer::DeclSerializer : public DeclVisitor<DeclSerializer> {
38193831 // simpler user model to just always desugar extension types.
38203832 extendedType = extendedType->getCanonicalType ();
38213833
3822- auto conformances = extension->getLocalConformances (
3823- ConformanceLookupKind::All);
3824-
38253834 SmallVector<TypeID, 8 > data;
3826- for (auto conformance : conformances)
3827- data.push_back (S.addConformanceRef (conformance));
3828-
3835+ size_t numConformances =
3836+ addConformances (extension, ConformanceLookupKind::All, data);
38293837 size_t numInherited = addInherited (
38303838 extension->getInherited (), data);
38313839
@@ -3848,7 +3856,7 @@ class Serializer::DeclSerializer : public DeclVisitor<DeclSerializer> {
38483856 extension->isImplicit (),
38493857 S.addGenericSignatureRef (
38503858 extension->getGenericSignature ()),
3851- conformances. size () ,
3859+ numConformances ,
38523860 numInherited,
38533861 data);
38543862
@@ -4052,14 +4060,10 @@ class Serializer::DeclSerializer : public DeclVisitor<DeclSerializer> {
40524060
40534061 auto contextID = S.addDeclContextRef (theStruct->getDeclContext ());
40544062
4055- auto conformances = theStruct->getLocalConformances (
4056- ConformanceLookupKind::All);
4057-
40584063 SmallVector<TypeID, 4 > data;
4059- for (auto conformance : conformances)
4060- data.push_back (S.addConformanceRef (conformance));
4061-
4062- unsigned numInherited = addInherited (theStruct->getInherited (), data);
4064+ size_t numConformances =
4065+ addConformances (theStruct, ConformanceLookupKind::All, data);
4066+ size_t numInherited = addInherited (theStruct->getInherited (), data);
40634067
40644068 llvm::SmallSetVector<Type, 4 > dependencyTypes;
40654069 for (Requirement req : theStruct->getGenericRequirements ()) {
@@ -4081,7 +4085,7 @@ class Serializer::DeclSerializer : public DeclVisitor<DeclSerializer> {
40814085 S.addGenericSignatureRef (
40824086 theStruct->getGenericSignature ()),
40834087 rawAccessLevel,
4084- conformances. size () ,
4088+ numConformances ,
40854089 numInherited,
40864090 data);
40874091
@@ -4096,14 +4100,10 @@ class Serializer::DeclSerializer : public DeclVisitor<DeclSerializer> {
40964100
40974101 auto contextID = S.addDeclContextRef (theEnum->getDeclContext ());
40984102
4099- auto conformances = theEnum->getLocalConformances (
4100- ConformanceLookupKind::All);
4101-
41024103 SmallVector<TypeID, 4 > data;
4103- for (auto conformance : conformances)
4104- data.push_back (S.addConformanceRef (conformance));
4105-
4106- unsigned numInherited = addInherited (theEnum->getInherited (), data);
4104+ size_t numConformances =
4105+ addConformances (theEnum, ConformanceLookupKind::All, data);
4106+ size_t numInherited = addInherited (theEnum->getInherited (), data);
41074107
41084108 llvm::SmallSetVector<Type, 4 > dependencyTypes;
41094109 for (const EnumElementDecl *nextElt : theEnum->getAllElements ()) {
@@ -4138,7 +4138,7 @@ class Serializer::DeclSerializer : public DeclVisitor<DeclSerializer> {
41384138 theEnum->getGenericSignature ()),
41394139 S.addTypeRef (theEnum->getRawType ()),
41404140 rawAccessLevel,
4141- conformances. size () ,
4141+ numConformances ,
41424142 numInherited,
41434143 data);
41444144
@@ -4153,14 +4153,10 @@ class Serializer::DeclSerializer : public DeclVisitor<DeclSerializer> {
41534153
41544154 auto contextID = S.addDeclContextRef (theClass->getDeclContext ());
41554155
4156- auto conformances = theClass->getLocalConformances (
4157- ConformanceLookupKind::NonInherited);
4158-
41594156 SmallVector<TypeID, 4 > data;
4160- for (auto conformance : conformances)
4161- data.push_back (S.addConformanceRef (conformance));
4162-
4163- unsigned numInherited = addInherited (theClass->getInherited (), data);
4157+ size_t numConformances =
4158+ addConformances (theClass, ConformanceLookupKind::NonInherited, data);
4159+ size_t numInherited = addInherited (theClass->getInherited (), data);
41644160
41654161 llvm::SmallSetVector<Type, 4 > dependencyTypes;
41664162 if (theClass->hasSuperclass ()) {
@@ -4197,7 +4193,7 @@ class Serializer::DeclSerializer : public DeclVisitor<DeclSerializer> {
41974193 theClass->getGenericSignature ()),
41984194 S.addTypeRef (theClass->getSuperclass ()),
41994195 rawAccessLevel,
4200- conformances. size () ,
4196+ numConformances ,
42014197 numInherited,
42024198 data);
42034199
0 commit comments