Use non-overlapping swap for inner heapsort loop

This regresses binary-size slightly for normal builds, but the important
release_lto_thin_opt_level_s config sees a small improvement in
binary-size and a larger types such as string and 1k see 2-3% run-time
improvements with this change.
This commit is contained in:
Lukas Bergdoll 2024-09-04 19:54:46 +02:00
parent a0e4303ba2
commit 5439198348

View file

@ -69,9 +69,7 @@ where
break;
}
// Swap `node` with the greater child, move one step down, and continue sifting. This
// could be ptr::swap_nonoverlapping but that adds a significant amount of binary-size.
ptr::swap(v_base.add(node), v_base.add(child));
ptr::swap_nonoverlapping(v_base.add(node), v_base.add(child), 1);
}
node = child;