Combine sort keys into u64/u128

This allows the compiler to perform branch-less comparisons, which are
more efficient.

This results in ~5% fewer instructions executed.
This commit is contained in:
Amanieu d'Antras
2022-01-11 10:38:50 +00:00
parent 053375f049
commit d95a9d9399
5 changed files with 44 additions and 10 deletions

View File

@@ -3,7 +3,7 @@
* exception. See `LICENSE` for details.
*/
use crate::Allocation;
use crate::{ion::data_structures::u64_key, Allocation};
use smallvec::{smallvec, SmallVec};
pub type MoveVec<T> = SmallVec<[(Allocation, Allocation, T); 16]>;
@@ -53,7 +53,8 @@ impl<T: Clone + Copy + Default> ParallelMoves<T> {
// Sort moves by source so that we can efficiently test for
// presence.
self.parallel_moves.sort_by_key(|&(src, dst, _)| (src, dst));
self.parallel_moves
.sort_by_key(|&(src, dst, _)| u64_key(src.bits(), dst.bits()));
// Do any dests overlap sources? If not, we can also just
// return the list.