@@ -253,11 +253,11 @@ void PotentialBindings::inferTransitiveProtocolRequirements(
253
253
const SmallPtrSetImpl<Constraint *> &transitive) {
254
254
auto &destination = protocols[dstVar];
255
255
256
- for ( auto *protocol : direct )
257
- destination.insert (protocol );
256
+ if (direct. size () > 0 )
257
+ destination.insert (direct. begin (), direct. end () );
258
258
259
- for ( auto *protocol : transitive )
260
- destination.insert (protocol );
259
+ if (transitive. size () > 0 )
260
+ destination.insert (transitive. begin (), transitive. end () );
261
261
};
262
262
263
263
addToWorkList (nullptr , TypeVar);
@@ -289,7 +289,7 @@ void PotentialBindings::inferTransitiveProtocolRequirements(
289
289
addToWorkList (currentVar, entry.first );
290
290
291
291
// If current type variable is part of an equivalence
292
- // class, make it a "representative" and let's it infer
292
+ // class, make it a "representative" and let it infer
293
293
// supertypes and direct protocol requirements from
294
294
// other members.
295
295
for (const auto &entry : bindings.EquivalentTo ) {
@@ -325,7 +325,7 @@ void PotentialBindings::inferTransitiveProtocolRequirements(
325
325
propagateProtocolsTo (parent, bindings.Protocols , protocols[currentVar]);
326
326
}
327
327
328
- auto inferredProtocols = std::move ( protocols[currentVar]) ;
328
+ auto & inferredProtocols = protocols[currentVar];
329
329
330
330
llvm::SmallPtrSet<Constraint *, 4 > protocolsForEquivalence;
331
331
@@ -348,13 +348,15 @@ void PotentialBindings::inferTransitiveProtocolRequirements(
348
348
auto eqBindings = inferredBindings.find (equivalence.first );
349
349
if (eqBindings != inferredBindings.end ()) {
350
350
auto &bindings = eqBindings->getSecond ();
351
- bindings.TransitiveProtocols .emplace (protocolsForEquivalence);
351
+ bindings.TransitiveProtocols .emplace (protocolsForEquivalence.begin (),
352
+ protocolsForEquivalence.end ());
352
353
}
353
354
}
354
355
355
356
// Update the bindings associated with current type variable,
356
357
// to avoid repeating this inference process.
357
- bindings.TransitiveProtocols .emplace (std::move (inferredProtocols));
358
+ bindings.TransitiveProtocols .emplace (inferredProtocols.begin (),
359
+ inferredProtocols.end ());
358
360
} while (!workList.empty ());
359
361
}
360
362
0 commit comments