1
0
Fork 0
mirror of https://github.com/BLAKE3-team/BLAKE3 synced 2024-05-28 09:36:03 +02:00

Update lib.rs

Minor performance improvements.
This commit is contained in:
K 2022-12-04 20:46:15 +02:00 committed by GitHub
parent 67e4d04a3c
commit a8ae6b4fa2
Signed by: GitHub
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -454,11 +454,10 @@ impl ChunkState {
// Try to avoid buffering as much as possible, by compressing directly from
// the input slice when full blocks are available.
fn update(&mut self, mut input: &[u8]) -> &mut Self {
if self.buf_len > 0 {
if !input.is_empty() && self.buf_len > 0 {
self.fill_buf(&mut input);
if !input.is_empty() {
debug_assert_eq!(self.buf_len as usize, BLOCK_LEN);
let block_flags = self.flags | self.start_flag(); // borrowck
let block_flags = self.flags | self.start_flag();
self.platform.compress_in_place(
&mut self.cv,
&self.buf,
@ -472,6 +471,7 @@ impl ChunkState {
}
}
while input.len() > BLOCK_LEN {
debug_assert_eq!(self.buf_len, 0);
let block_flags = self.flags | self.start_flag(); // borrowck