From 93c7bacb29405b83c15fde8c315f36a84d607601 Mon Sep 17 00:00:00 2001 From: Arseny Kapoulkine Date: Tue, 26 Feb 2019 21:35:05 -0800 Subject: [PATCH] XPath: Create set for a|b in order before duplicate filtering 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 #254. --- src/pugixml.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/pugixml.cpp b/src/pugixml.cpp index 57bd50a..adafb3d 100644 --- a/src/pugixml.cpp +++ b/src/pugixml.cpp @@ -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: