1
0
mirror of https://github.com/actix/actix-extras.git synced 2025-06-26 18:37:41 +02:00

optimize websocket stream

This commit is contained in:
Nikolay Kim
2018-03-08 17:19:50 -08:00
parent 395243a539
commit ebdc983dfe
7 changed files with 123 additions and 37 deletions

View File

@ -27,7 +27,7 @@ impl SharedBytesPool {
pub fn release_bytes(&self, mut bytes: Rc<BytesMut>) {
let v = &mut self.0.borrow_mut();
if v.len() < 128 {
Rc::get_mut(&mut bytes).unwrap().take();
Rc::get_mut(&mut bytes).unwrap().clear();
v.push_front(bytes);
}
}
@ -62,7 +62,7 @@ impl SharedBytes {
#[inline(always)]
#[allow(mutable_transmutes)]
#[cfg_attr(feature = "cargo-clippy", allow(mut_from_ref, inline_always))]
pub fn get_mut(&self) -> &mut BytesMut {
pub(crate) fn get_mut(&self) -> &mut BytesMut {
let r: &BytesMut = self.0.as_ref().unwrap().as_ref();
unsafe{mem::transmute(r)}
}