Skip to content

Commit

Permalink
Optimize get_split utility
Browse files Browse the repository at this point in the history
Throughput of ondemand binary deserializer improves 0-6%.

Looked into it a bit and I'm not sure where the throughput improvement
comes from as this method generates more assembly.
  • Loading branch information
nickbabcock committed Nov 11, 2023
1 parent 17c889b commit 78c65f5
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,7 @@ fn take<const N: usize>(data: &[u8]) -> [u8; N] {

#[inline]
pub(crate) fn get_split<const N: usize>(data: &[u8]) -> Option<([u8; N], &[u8])> {
if N <= data.len() {
let (head, tail) = data.split_at(N);
Some((take::<N>(head), tail))
} else {
None
}
data.get(N..).map(|d| (take::<N>(data), d))
}

#[inline]
Expand Down

0 comments on commit 78c65f5

Please sign in to comment.