@@ -1473,21 +1473,21 @@ InversionCandidate* Retrieval::makeInversion(InversionCandidateList& inversions)
14731473 invCandidate->nonFullMatchedSegments = 0 ;
14741474 invCandidate->matchedSegments = currentInv->matchedSegments ;
14751475 invCandidate->dependencies = currentInv->dependencies ;
1476- matches.clear ();
14771476
14781477 for (const auto currentMatch : currentInv->matches )
14791478 {
1480- if (!matches.exist (currentMatch))
1481- matches.add (currentMatch);
1479+ if (!invCandidate-> matches .exist (currentMatch))
1480+ invCandidate-> matches .add (currentMatch);
14821481 }
14831482
1484- if (currentInv->boolean )
1483+ if (const auto currentMatch = currentInv->boolean )
14851484 {
1486- if (!matches.exist (currentInv-> boolean ))
1487- matches.add (currentInv-> boolean );
1485+ if (!invCandidate-> matches .exist (currentMatch ))
1486+ invCandidate-> matches .add (currentMatch );
14881487 }
14891488
1490- invCandidate->matches .join (matches);
1489+ matches.assign (invCandidate->matches );
1490+
14911491 if (customPlan)
14921492 continue ;
14931493
@@ -1661,16 +1661,19 @@ InversionCandidate* Retrieval::makeInversion(InversionCandidateList& inversions)
16611661 invCandidate->dependencies = bestCandidate->dependencies ;
16621662 invCandidate->condition = bestCandidate->condition ;
16631663
1664- for (FB_SIZE_T j = 0 ; j < bestCandidate->matches . getCount (); j++ )
1664+ for (const auto bestMatch : bestCandidate->matches )
16651665 {
1666- if (!matches.exist (bestCandidate-> matches [j] ))
1667- matches.add (bestCandidate-> matches [j] );
1666+ if (!invCandidate-> matches .exist (bestMatch ))
1667+ invCandidate-> matches .add (bestMatch );
16681668 }
1669- if (bestCandidate->boolean )
1669+
1670+ if (const auto bestMatch = bestCandidate->boolean )
16701671 {
1671- if (!matches.exist (bestCandidate-> boolean ))
1672- matches.add (bestCandidate-> boolean );
1672+ if (!invCandidate-> matches .exist (bestMatch ))
1673+ invCandidate-> matches .add (bestMatch );
16731674 }
1675+
1676+ matches.join (invCandidate->matches );
16741677 }
16751678 else if (!bestCandidate->condition )
16761679 {
@@ -1697,15 +1700,17 @@ InversionCandidate* Retrieval::makeInversion(InversionCandidateList& inversions)
16971700
16981701 for (const auto bestMatch : bestCandidate->matches )
16991702 {
1700- if (!matches.exist (bestMatch))
1701- matches.add (bestMatch);
1703+ if (!invCandidate-> matches .exist (bestMatch))
1704+ invCandidate-> matches .add (bestMatch);
17021705 }
17031706
1704- if (bestCandidate->boolean )
1707+ if (const auto bestMatch = bestCandidate->boolean )
17051708 {
1706- if (!matches.exist (bestCandidate-> boolean ))
1707- matches.add (bestCandidate-> boolean );
1709+ if (!invCandidate-> matches .exist (bestMatch ))
1710+ invCandidate-> matches .add (bestMatch );
17081711 }
1712+
1713+ matches.join (invCandidate->matches );
17091714 }
17101715
17111716 if (invCandidate->unique )
@@ -1739,10 +1744,13 @@ InversionCandidate* Retrieval::makeInversion(InversionCandidateList& inversions)
17391744 invCandidate->cost += navigationCandidate->cost ;
17401745 ++invCandidate->indexes ;
17411746 invCandidate->navigated = true ;
1742- }
17431747
1744- if (invCandidate)
1745- invCandidate->matches .join (matches);
1748+ for (const auto navMatch : navigationCandidate->matches )
1749+ {
1750+ if (!invCandidate->matches .exist (navMatch))
1751+ invCandidate->matches .add (navMatch);
1752+ }
1753+ }
17461754
17471755 return invCandidate;
17481756}
0 commit comments