@@ -1491,30 +1491,6 @@ static Surrounding_context qt2sc(Query_term_type qtt) {
1491
1491
return SC_TOP;
1492
1492
}
1493
1493
1494
- // / Append the children of 'lower' to those of 'setop'. To avoid excessive
1495
- // / space usage of a large number of similar set ops: instead of the "obvious"
1496
- // / method of copying the operands of the child's array to the parent's array,
1497
- // / we may use the (possibly much) larger lower setop's child array as a basis,
1498
- // / inserting setop's childen at the front and then std::move'ing that (now
1499
- // / discarded) array to be setop's child array. This makes the space
1500
- // / allocation ~= linear instead of O(N*N/2) in the worst case (N: # of set
1501
- // / operations).
1502
- void PT_set_operation::merge_children (Query_term_set_op *setop,
1503
- Query_term_set_op *lower) {
1504
- if (lower->m_children .size () <= setop->m_children .size ()) {
1505
- for (auto child : lower->m_children ) {
1506
- setop->m_children .push_back (child);
1507
- }
1508
- } else {
1509
- const size_t lim = setop->m_children .size () - 1 ;
1510
- for (size_t i = 0 ; i < setop->m_children .size (); ++i) {
1511
- lower->m_children .push_front (setop->m_children [lim - i]);
1512
- }
1513
- setop->m_children = std::move (lower->m_children );
1514
- // lower->m_children is now empty.
1515
- }
1516
- }
1517
-
1518
1494
/* *
1519
1495
Possibly merge lower syntactic levels of set operations (UNION, INTERSECT and
1520
1496
EXCEPT) into setop, and set new last DISTINCT index for setop. We only ever
@@ -1677,7 +1653,8 @@ void PT_set_operation::merge_descendants(Parse_context *pc,
1677
1653
// distinct
1678
1654
last_distinct = count + lower->m_children .size () - 1 ;
1679
1655
count = count + lower->m_children .size ();
1680
- merge_children (setop, lower);
1656
+ // fold in children
1657
+ for (auto child : lower->m_children ) setop->m_children .push_back (child);
1681
1658
} else {
1682
1659
// similar kind of set operation, but contains limit, so do not merge
1683
1660
count++;
@@ -1716,7 +1693,8 @@ void PT_set_operation::merge_descendants(Parse_context *pc,
1716
1693
}
1717
1694
last_distinct = count + lower->m_last_distinct ;
1718
1695
count = count + lower->m_children .size ();
1719
- merge_children (setop, lower);
1696
+ for (auto child : lower->m_children )
1697
+ setop->m_children .push_back (child);
1720
1698
}
1721
1699
} else {
1722
1700
// upper and lower level are both ALL, so ok to merge, unless we have
@@ -1727,7 +1705,8 @@ void PT_set_operation::merge_descendants(Parse_context *pc,
1727
1705
first_distinct = count + lower->m_first_distinct ;
1728
1706
}
1729
1707
count = count + lower->m_children .size ();
1730
- merge_children (setop, lower);
1708
+ for (auto child : lower->m_children )
1709
+ setop->m_children .push_back (child);
1731
1710
} else {
1732
1711
// do not merge INTERSECT ALL: the execution time logic can only
1733
1712
// handle binary INTERSECT ALL.
@@ -1746,7 +1725,7 @@ void PT_set_operation::merge_descendants(Parse_context *pc,
1746
1725
first_distinct = count + lower->m_first_distinct ;
1747
1726
}
1748
1727
count = count + lower->m_children .size ();
1749
- merge_children (setop, lower);
1728
+ for ( auto child : lower-> m_children ) setop-> m_children . push_back (child );
1750
1729
} else {
1751
1730
// do not merge
1752
1731
count++;
0 commit comments