Skip to content

Commit 61cacb6

Browse files
committed
perf(net): convert Bytes to BytesMut can avoid reallocation
1 parent 2f9281b commit 61cacb6

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

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)