33
44#include " xss-network-qsort.hpp"
55
6+ enum class pivot_result_t : int { Normal, Sorted, Only2Values };
7+
68template <typename type_t >
79struct pivot_results {
8- bool alreadySorted = false ;
9- bool only2Values = false ;
10- type_t pivot = 0 ;
1110
12- pivot_results (type_t _pivot){
13- pivot = _pivot;
14- alreadySorted = false ;
15- }
11+ pivot_result_t result = pivot_result_t ::Normal;
12+ type_t pivot = 0 ;
1613
17- pivot_results (type_t _pivot, bool _alreadySorted ){
14+ pivot_results (type_t _pivot, pivot_result_t _result = pivot_result_t ::Normal ){
1815 pivot = _pivot;
19- alreadySorted = _alreadySorted ;
16+ result = _result ;
2017 }
2118};
2219
@@ -197,7 +194,7 @@ X86_SIMD_SORT_INLINE pivot_results<type_t> get_pivot_near_constant(type_t *arr,
197194 if (index == right + 1 ){
198195 // The array is completely constant
199196 // Setting the second flag to true skips partitioning, as the array is constant and thus sorted
200- return pivot_results<type_t >(commonValue, true );
197+ return pivot_results<type_t >(commonValue, pivot_result_t ::Sorted );
201198 }
202199
203200 // Secondly, search for a second value not equal to either of the previous two
@@ -224,9 +221,7 @@ X86_SIMD_SORT_INLINE pivot_results<type_t> get_pivot_near_constant(type_t *arr,
224221 // We can also skip recursing, as it is guaranteed both partitions are constant after partitioning with the larger value
225222 // TODO this logic now assumes we use greater than or equal to specifically when partitioning, might be worth noting that somewhere
226223 type_t pivot = std::max (value1, commonValue, comparison_func<vtype>);
227- auto result = pivot_results<type_t >(pivot, false );
228- result.only2Values = true ;
229- return result;
224+ return pivot_results<type_t >(pivot, pivot_result_t ::Only2Values);
230225 }
231226
232227 // The array has at least 3 distinct values. Use the middle one as the pivot
0 commit comments