Skip to content

Commit

Permalink
perf: improve Bytes::copy_to_bytes (#688)
Browse files Browse the repository at this point in the history
Signed-off-by: tison <wander4096@gmail.com>
  • Loading branch information
tisonkun committed Apr 10, 2024
1 parent 4eb62b9 commit b5fbfc3
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions src/bytes.rs
Expand Up @@ -582,13 +582,7 @@ impl Buf for Bytes {
}

fn copy_to_bytes(&mut self, len: usize) -> Self {
if len == self.remaining() {
core::mem::replace(self, Bytes::new())
} else {
let ret = self.slice(..len);
self.advance(len);
ret
}
self.split_to(len)
}
}

Expand Down

0 comments on commit b5fbfc3

Please sign in to comment.