Skip to content

Commit b453779

Browse files
committed
perf(net): convert Bytes to BytesMut can avoid reallocation
1 parent e810df9 commit b453779

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

crates/net/eth-wire/src/multiplex.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,9 +332,9 @@ impl ProtocolProxy {
332332
return Ok(msg);
333333
}
334334

335-
let mut masked = Vec::from(msg);
335+
let mut masked: BytesMut = msg.into();
336336
masked[0] = masked[0].checked_add(offset).ok_or(io::ErrorKind::InvalidInput)?;
337-
Ok(masked.into())
337+
Ok(masked.freeze())
338338
}
339339

340340
/// Unmasks the message ID of a message received from the wire.

0 commit comments

Comments
 (0)