split csv and json document routes

This commit is contained in:
mpostma 2021-09-29 00:12:25 +02:00
parent 6e8a3fe8de
commit 911630000f
4 changed files with 49 additions and 48 deletions

View file

@ -67,8 +67,9 @@ impl<S: Stream<Item = std::result::Result<Bytes, PayloadError>> + Unpin> io::Rea
// TODO: optimize buf filling
match self.current.take() {
Some(mut bytes) => {
let copied = bytes.split_to(buf.len());
buf.copy_from_slice(&copied);
let split_at = bytes.len().min(buf.len());
let copied = bytes.split_to(split_at);
buf[..split_at].copy_from_slice(&copied);
if !bytes.is_empty() {
self.current.replace(bytes);
}