Skip to content

Commit

Permalink
opt: get_power_of_two_ceil
Browse files Browse the repository at this point in the history
  • Loading branch information
ralexstokes committed Mar 30, 2024
1 parent 62bc724 commit a163ef9
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions ssz-rs/src/merkleization/generalized_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,9 @@ pub fn log_2(x: usize) -> Option<u32> {
x.checked_ilog2()
}

#[inline]
pub fn get_power_of_two_ceil(x: usize) -> usize {
match x {
x if x <= 1 => 1,
2 => 2,
x => 2 * get_power_of_two_ceil((x + 1) / 2),
}
x.next_power_of_two()
}

/// Represents a "generalized index" from the SSZ spec.
Expand Down

0 comments on commit a163ef9

Please sign in to comment.