mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-30 04:57:57 +00:00
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:
committed by
Robert Habermeier
parent
2d6e617309
commit
1baee72d75
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user