Skip to content

Commit

Permalink
apply_mask use vec as mut type
Browse files Browse the repository at this point in the history
  • Loading branch information
alexheretic committed Dec 17, 2024
1 parent c117f1a commit 487bd5c
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/protocol/frame/frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::{
default::Default,
fmt,
io::{Cursor, ErrorKind, Read, Write},
mem,
result::Result as StdResult,
str::Utf8Error,
string::String,
Expand Down Expand Up @@ -248,12 +249,6 @@ impl Frame {
&self.payload
}

// /// Get a mutable reference to the frame's payload.
// #[inline]
// pub fn payload_mut(&mut self) -> &mut [u8] {
// self.payload.as_mut_slice()
// }

/// Test whether the frame is masked.
#[inline]
pub(crate) fn is_masked(&self) -> bool {
Expand All @@ -274,9 +269,9 @@ impl Frame {
#[inline]
pub(crate) fn apply_mask(&mut self) {
if let Some(mask) = self.header.mask.take() {
let mut bytes_mut = BytesMut::from(std::mem::take(&mut self.payload));
apply_mask(&mut bytes_mut, mask);
self.payload = bytes_mut.freeze();
let mut data = Vec::from(mem::take(&mut self.payload));
apply_mask(&mut data, mask);
self.payload = data.into();
}
}

Expand Down

0 comments on commit 487bd5c

Please sign in to comment.