massive speed improvements

This commit is contained in:
Toshit Chawda 2024-07-05 16:03:55 -07:00
parent b22ff47f19
commit 4f0a362390
No known key found for this signature in database
GPG key ID: 91480ED99E2B3D9D
10 changed files with 282 additions and 89 deletions

View file

@ -9,6 +9,15 @@ use tokio::io::{AsyncRead, AsyncWrite};
use crate::{ws::LockedWebSocketWrite, WispError};
fn match_payload(payload: Payload) -> BytesMut {
match payload {
Payload::Bytes(x) => x,
Payload::Owned(x) => BytesMut::from(x.deref()),
Payload::BorrowedMut(x) => BytesMut::from(x.deref()),
Payload::Borrowed(x) => BytesMut::from(x),
}
}
impl From<OpCode> for crate::ws::OpCode {
fn from(opcode: OpCode) -> Self {
use OpCode::*;
@ -30,7 +39,7 @@ impl From<Frame<'_>> for crate::ws::Frame {
Self {
finished: frame.fin,
opcode: frame.opcode.into(),
payload: BytesMut::from(frame.payload.deref()),
payload: match_payload(frame.payload),
}
}
}