Skip to content

Commit

Permalink
Merge pull request #128 from rakaly/opt-split
Browse files Browse the repository at this point in the history
Optimize `get_split` utility
  • Loading branch information
nickbabcock authored Nov 12, 2023
2 parents 25db2e5 + 78c65f5 commit 4572713
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 4572713

Please sign in to comment.