summaryrefslogtreecommitdiffstats
path: root/tokio-util
diff options
context:
space:
mode:
authorMarkus Westerlind <markus.westerlind@distilnetworks.com>2020-01-30 20:26:19 +0100
committerGitHub <noreply@github.com>2020-01-30 11:26:19 -0800
commitc3d56b85c318c3cdc164558c722b9440d443dcea (patch)
tree83576962225d5b91ff39d9dc2fd8df639807a396 /tokio-util
parent1eee6508fc85bb7d0043436075562632262da714 (diff)
codec: use advance over split_to when data is not needed (#2198)
Diffstat (limited to 'tokio-util')
-rw-r--r--tokio-util/src/codec/framed_write.rs5
-rw-r--r--tokio-util/src/codec/length_delimited.rs2
2 files changed, 3 insertions, 4 deletions
diff --git a/tokio-util/src/codec/framed_write.rs b/tokio-util/src/codec/framed_write.rs
index ca77b3d8..71b331fe 100644
--- a/tokio-util/src/codec/framed_write.rs
+++ b/tokio-util/src/codec/framed_write.rs
@@ -7,7 +7,7 @@ use tokio::{
stream::Stream,
};
-use bytes::BytesMut;
+use bytes::{Buf, BytesMut};
use futures_core::ready;
use futures_sink::Sink;
use log::trace;
@@ -239,8 +239,7 @@ where
.into()));
}
- // TODO: Add a way to `bytes` to do this w/o returning the drained data.
- let _ = pinned.buffer.split_to(n);
+ pinned.buffer.advance(n);
}
// Try flushing the underlying IO
diff --git a/tokio-util/src/codec/length_delimited.rs b/tokio-util/src/codec/length_delimited.rs
index 01ba2aec..04061c0a 100644
--- a/tokio-util/src/codec/length_delimited.rs
+++ b/tokio-util/src/codec/length_delimited.rs
@@ -494,7 +494,7 @@ impl LengthDelimitedCodec {
let num_skip = self.builder.get_num_skip();
if num_skip > 0 {
- let _ = src.split_to(num_skip);
+ src.advance(num_skip);
}
// Ensure that the buffer has enough space to read the incoming