Skip to content

Commit 9cd413d

Browse files
committed
Fix massive performance issue
The new version is multiple orders of magnitue faster than the old version.
1 parent 7bcb8fb commit 9cd413d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/message.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -356,8 +356,9 @@ fn read_data_row<R: BufRead>(buf: &mut R) -> io::Result<BackendMessage> {
356356
let val = match try!(buf.read_i32::<BigEndian>()) {
357357
-1 => None,
358358
len => {
359-
let mut data = vec![];
360-
try!(buf.take(len as u64).read_to_end(&mut data));
359+
let mut data = Vec::with_capacity(len as usize);
360+
data.extend((0..len).map(|_| 0));
361+
try!(util::read_all(buf, &mut data));
361362
Some(data)
362363
}
363364
};

0 commit comments

Comments
 (0)