mirror of
https://github.com/fafhrd91/actix-net
synced 2025-06-28 14:30:36 +02:00
Improve bcodec encode performance (#157)
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
use bytes::{BufMut, Bytes, BytesMut};
|
||||
use bytes::{Bytes, BytesMut, Buf};
|
||||
use std::io;
|
||||
|
||||
use super::{Decoder, Encoder};
|
||||
@ -12,9 +12,9 @@ pub struct BytesCodec;
|
||||
impl Encoder<Bytes> for BytesCodec {
|
||||
type Error = io::Error;
|
||||
|
||||
#[inline]
|
||||
fn encode(&mut self, item: Bytes, dst: &mut BytesMut) -> Result<(), Self::Error> {
|
||||
dst.reserve(item.len());
|
||||
dst.put(item);
|
||||
dst.extend_from_slice(item.bytes());
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user