Skip to content

Commit

Permalink
Fix massive performance issue
Browse files Browse the repository at this point in the history
The new version is multiple orders of magnitue faster than the old
version.
  • Loading branch information
sfackler committed Mar 27, 2015
1 parent 7bcb8fb commit 9cd413d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,9 @@ fn read_data_row<R: BufRead>(buf: &mut R) -> io::Result<BackendMessage> {
let val = match try!(buf.read_i32::<BigEndian>()) {
-1 => None,
len => {
let mut data = vec![];
try!(buf.take(len as u64).read_to_end(&mut data));
let mut data = Vec::with_capacity(len as usize);
data.extend((0..len).map(|_| 0));
try!(util::read_all(buf, &mut data));
Some(data)
}
};
Expand Down

0 comments on commit 9cd413d

Please sign in to comment.