Skip to content

Commit e62b4df

Browse files
committed
Optimize copy_in a bit
io::copy has to first copy onto the stack and then into the writer, but we can just explicitly call read_to_end which knows it's dealing with a Vec.
1 parent 913678e commit e62b4df

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1577,12 +1577,12 @@ impl<'conn> Statement<'conn> {
15771577

15781578
let mut buf = vec![];
15791579
loop {
1580-
match std::io::copy(&mut r.take(16 * 1024), &mut buf) {
1580+
match r.take(16 * 1024).read_to_end(&mut buf) {
15811581
Ok(0) => break,
1582-
Ok(len) => {
1582+
Ok(_) => {
15831583
try_desync!(conn, conn.stream.write_message(
15841584
&CopyData {
1585-
data: &buf[..len as usize],
1585+
data: &buf,
15861586
}));
15871587
buf.clear();
15881588
}

0 commit comments

Comments
 (0)