Skip to content

Commit

Permalink
Move merge_tree_scale_factor
Browse files Browse the repository at this point in the history
  • Loading branch information
orlp committed Mar 10, 2024
1 parent 665df17 commit 2547978
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/drift.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,14 @@ pub fn sort<T, F: FnMut(&T, &T) -> bool>(
// x < 2^63 + 2n
// So as long as n < 2^62 we find that x < 2^64, meaning our operations do not
// overflow.
#[inline(always)]
fn merge_tree_scale_factor(n: usize) -> u64 {
if usize::BITS > u64::BITS {
panic!("Platform not supported");
}

((1 << 62) + n as u64 - 1) / n as u64
}

// Note: merge_tree_depth output is < 64 when left < right as f*x and f*y must
// differ in some bit, and is <= 64 always.
Expand Down Expand Up @@ -206,15 +214,6 @@ fn logical_merge<T, F: FnMut(&T, &T) -> bool>(
}
}

#[inline(always)]
fn merge_tree_scale_factor(n: usize) -> u64 {
if usize::BITS > u64::BITS {
panic!("Platform not supported");
}

((1 << 62) + n as u64 - 1) / n as u64
}

/// Creates a new logical run.
///
/// A logical run can either be sorted or unsorted. If there is a pre-existing run that clears the
Expand Down

0 comments on commit 2547978

Please sign in to comment.