Skip to content

Commit

Permalink
XPath: Create set for a|b in order before duplicate filtering
Browse files Browse the repository at this point in the history
This does not change the result of a union operation [substantially], but
it means that we now give a list to remove_duplicates that has more natural
ordering.

If remove_duplicates didn't sort the array, we'd have union operations
resulting in a consistent predictable order.

Contributes to zeux#254.
  • Loading branch information
zeux committed Feb 27, 2019
1 parent d902709 commit 93c7bac
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/pugixml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10737,16 +10737,16 @@ PUGI__NS_BEGIN

xpath_stack swapped_stack = {stack.temp, stack.result};

xpath_node_set_raw ls = _left->eval_node_set(c, swapped_stack, eval);
xpath_node_set_raw rs = _right->eval_node_set(c, stack, eval);
xpath_node_set_raw ls = _left->eval_node_set(c, stack, eval);
xpath_node_set_raw rs = _right->eval_node_set(c, swapped_stack, eval);

// we can optimize merging two sorted sets, but this is a very rare operation, so don't bother
rs.set_type(xpath_node_set::type_unsorted);
ls.set_type(xpath_node_set::type_unsorted);

rs.append(ls.begin(), ls.end(), stack.result);
rs.remove_duplicates();
ls.append(rs.begin(), rs.end(), stack.result);
ls.remove_duplicates();

return rs;
return ls;
}

case ast_filter:
Expand Down

0 comments on commit 93c7bac

Please sign in to comment.