@@ -1494,45 +1494,69 @@ InversionCandidate* Retrieval::makeInversion(InversionCandidateList& inversions)
14941494 return invCandidate;
14951495 }
14961496
1497- // Look if a match is already used by previous matches.
1498- bool anyMatchAlreadyUsed = false , matchUsedByNavigation = false ;
1499- for (const auto currentMatch : currentInv->matches )
1497+ if (!customPlan)
15001498 {
1501- if (matches.exist (currentMatch))
1502- {
1503- anyMatchAlreadyUsed = true ;
1499+ // Look if a match is already used by previous matches
1500+ bool anyMatchAlreadyUsed = false , matchUsedByNavigation = false ;
15041501
1505- if (navigationCandidate &&
1506- navigationCandidate->matches .exist (currentMatch))
1502+ for (const auto currentMatch : currentInv->matches )
1503+ {
1504+ if (matches.exist (currentMatch))
15071505 {
1508- matchUsedByNavigation = true ;
1509- }
1506+ anyMatchAlreadyUsed = true ;
15101507
1511- break ;
1508+ if (navigationCandidate &&
1509+ navigationCandidate->matches .exist (currentMatch))
1510+ {
1511+ matchUsedByNavigation = true ;
1512+ }
1513+
1514+ break ;
1515+ }
15121516 }
1513- }
15141517
1515- if (currentInv->boolean && matches.exist (currentInv->boolean ))
1516- anyMatchAlreadyUsed = true ;
1518+ if (const auto currentMatch = currentInv->boolean )
1519+ {
1520+ if (matches.exist (currentMatch))
1521+ {
1522+ anyMatchAlreadyUsed = true ;
15171523
1518- if (anyMatchAlreadyUsed && !customPlan)
1519- {
1520- currentInv->used = true ;
1524+ if (navigationCandidate &&
1525+ navigationCandidate->matches .exist (currentMatch))
1526+ {
1527+ matchUsedByNavigation = true ;
1528+ }
1529+ }
1530+ else if (matchUsedByNavigation)
1531+ anyMatchAlreadyUsed = false ;
1532+ }
15211533
1522- if (matchUsedByNavigation)
1523- continue ;
1534+ // If some match was already used by another index, skip this index
15241535
1525- // If a match on this index was already used by another
1526- // index, add also the other matches from this index.
1527- for (const auto currentMatch : currentInv->matches )
1536+ if (anyMatchAlreadyUsed)
15281537 {
1529- if (!matches.exist (currentMatch))
1530- matches.add (currentMatch);
1531- }
1538+ if (!matchUsedByNavigation)
1539+ {
1540+ // Add the other matches from this index
1541+
1542+ for (const auto currentMatch : currentInv->matches )
1543+ {
1544+ if (!matches.exist (currentMatch))
1545+ matches.add (currentMatch);
1546+ }
1547+
1548+ if (const auto currentMatch = currentInv->boolean )
1549+ {
1550+ if (!matches.exist (currentMatch))
1551+ matches.add (currentMatch);
1552+ }
1553+ }
15321554
1533- // Restart loop, because other indexes could also be excluded now.
1534- restartLoop = true ;
1535- break ;
1555+ // Restart loop, because other indexes could also be excluded now
1556+ currentInv->used = true ;
1557+ restartLoop = true ;
1558+ break ;
1559+ }
15361560 }
15371561
15381562 if (!bestCandidate)
0 commit comments