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:
AshleyandAndré Silva authored and Robert Habermeier committed 2019-09-23 22:37:53 +02:00
1 parent 2d6e617309
commit 1baee72d75
3 files changed
+10 -2

No files matched your search

+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)