Rounding functions in storage.rs differ a little, intentional? #308
-
Hi ! In let req_pos = round_down_to_multiple(pos, 4);
let req_len = round_up_to_multiple(len, 4).max(MINIMUM_READ_LENGTH); ( Rounding down / up to nearest 4-byre alignment? ) Looking at those two rounding functions, it appears they behave a bit different when Thanks in advance for your thoughts! Played around on the playground: Round down n: 11 to multiples of m: 4 gives: 8
Round down n: 12 to multiples of m: 4 gives: 12
Round down n: 13 to multiples of m: 4 gives: 12
current round-up
Round up n: 11 to multiples of m: 4 gives: 12
Round up n: 12 to multiples of m: 4 gives: 16
Round up n: 13 to multiples of m: 4 gives: 16
Alternative round-up (symmetric to round down):
Round up n: 11 to multiples of m: 4 gives: 12
Round up n: 12 to multiples of m: 4 gives: 12
Round up n: 13 to multiples of m: 4 gives: 16
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @luukvanderduim, thanks for looking into Psst's code-base! Honestly, I think we could remove the functions entirely, as there's no 4-byte-alignment requirement now for the chunk-fetching mechanism (unlike before).
|
Beta Was this translation helpful? Give feedback.
Hi @luukvanderduim, thanks for looking into Psst's code-base!
Honestly, I think we could remove the functions entirely, as there's no 4-byte-alignment requirement now for the chunk-fetching mechanism (unlike before).
#[inline]
matters only when inlining across crates, which is not the case here.