@@ -562,53 +562,34 @@ void BindingSet::determineLiteralCoverage() {
562
562
563
563
bool allowsNil = canBeNil ();
564
564
565
- for (auto binding = Bindings.begin (); binding != Bindings.end ();) {
566
- bool isCovered = false ;
567
- Type adjustedTy;
568
-
569
- // Tracks the number of covered literal requirements,
570
- // so checking could be stopped as soon as all of the
571
- // requirements are satisfied.
572
- unsigned numCoveredRequirements = 0 ;
573
- for (auto &literalRequirement : Literals) {
574
- auto &literalInfo = literalRequirement.second ;
575
-
576
- if (!literalInfo.viableAsBinding ()) {
577
- ++numCoveredRequirements;
578
- continue ;
579
- }
565
+ for (auto &entry : Literals) {
566
+ auto &literal = entry.second ;
567
+
568
+ if (!literal.viableAsBinding ())
569
+ continue ;
570
+
571
+ for (auto binding = Bindings.begin (); binding != Bindings.end ();
572
+ ++binding) {
573
+
574
+ bool isCovered = false ;
575
+ Type adjustedTy;
580
576
581
577
std::tie (isCovered, adjustedTy) =
582
- literalInfo .isCoveredBy (*binding, allowsNil, CS.DC );
578
+ literal .isCoveredBy (*binding, allowsNil, CS.DC );
583
579
584
- if (isCovered) {
585
- literalInfo.setCoveredBy (binding->getSource ());
586
- ++numCoveredRequirements;
587
- break ;
588
- }
589
- }
580
+ if (!isCovered)
581
+ continue ;
590
582
591
- // If the type has been adjusted, we need to re-insert
592
- // the binding but skip all of the previous checks.
593
- //
594
- // It's okay to do this here since iteration stops after
595
- // first covering binding has been found.
596
- if (isCovered && adjustedTy) {
597
- binding = Bindings.erase (binding);
598
- adjustedBindings.push_back (binding->withType (adjustedTy));
599
- continue ;
600
- }
583
+ literal.setCoveredBy (binding->getSource ());
601
584
602
- // If all of the literal requirements are now covered
603
- // by existing bindings, there is nothing left to do.
604
- if (numCoveredRequirements == Literals. size ())
605
- break ;
585
+ if (adjustedTy) {
586
+ Bindings. erase (binding);
587
+ Bindings. insert (binding-> withType (adjustedTy));
588
+ }
606
589
607
- ++binding;
590
+ break ;
591
+ }
608
592
}
609
-
610
- for (auto &newBinding : adjustedBindings)
611
- (void )Bindings.insert (std::move (newBinding));
612
593
}
613
594
614
595
void BindingSet::addLiteralRequirement (Constraint *constraint) {
0 commit comments