use pdqselect for median_algorithm selection (#3636)

* use pdqselect for median_algorithm selection instead of sorting the whole vec

* Make use of pqdselect clearer

Co-Authored-By: André Silva <andre.beat@gmail.com>

* Make use of pqdselect clearer

Co-Authored-By: André Silva <andre.beat@gmail.com>
This commit is contained in:
Ashley
2019-09-24 08:37:53 +12:00
committed by Robert Habermeier
parent 2d6e617309
commit 1baee72d75
3 changed files with 10 additions and 2 deletions
+2 -2
View File
@@ -780,8 +780,8 @@ fn median_algorithm(
t + Duration::new(secs, nanos)
}).collect();
// FIXME #2926: use a selection algorithm instead of a full sorting algorithm.
new_list.sort_unstable();
// Use a partial sort to move the median timestamp to the middle of the list
pdqselect::select(&mut new_list, num_timestamps / 2);
let &median = new_list
.get(num_timestamps / 2)