Skip to content

Commit 56709ae

Browse files
authored
[ISSUE #2357]🤡Use RemotingCommand take_body method for performance🧑‍💻 (#2358)
1 parent 36d468b commit 56709ae

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

‎rocketmq-remoting/src/codec/remoting_command_codec.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ impl Encoder<RemotingCommand> for RemotingCommandCodec {
121121
fn encode(&mut self, item: RemotingCommand, dst: &mut BytesMut) -> Result<(), Self::Error> {
122122
let mut item = item;
123123
item.fast_header_encode(dst);
124-
if let Some(body_inner) = item.get_body() {
125-
dst.put(body_inner.as_ref());
124+
if let Some(body_inner) = item.take_body() {
125+
dst.put(body_inner);
126126
}
127127
Ok(())
128128
}

‎rocketmq-remoting/src/protocol/remoting_command.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,7 @@ impl RemotingCommand {
599599
&self.body
600600
}
601601

602+
#[inline]
602603
pub fn take_body(&mut self) -> Option<Bytes> {
603604
self.body.take()
604605
}

0 commit comments

Comments
 (0)