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