Skip to content

Commit

Permalink
[git-packetline] Fix performance regression
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed May 13, 2021
1 parent 1c13706 commit 513e7ad
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion git-packetline/src/read/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ where
buf: &'a mut Vec<u8>,
delimiters: &[PacketLine<'static>],
fail_on_err_lines: bool,
buf_resize: bool,
) -> (
bool,
Option<PacketLine<'static>>,
Expand All @@ -121,7 +122,9 @@ where
.as_slice()
.map(|s| s.len() + U16_HEX_BYTES)
.unwrap_or(U16_HEX_BYTES);
buf.resize(len, 0);
if buf_resize {
buf.resize(len, 0);
}
Ok(Ok(crate::decode(buf).expect("only valid data here")))
}
Ok(Err(err)) => {
Expand Down Expand Up @@ -160,6 +163,7 @@ where
&mut self.buf,
&self.delimiters,
self.fail_on_err_lines,
false,
);
self.is_done = is_done;
self.stopped_at = stopped_at;
Expand Down Expand Up @@ -197,6 +201,7 @@ where
&mut self.peek_buf,
&self.delimiters,
self.fail_on_err_lines,
true,
);
self.is_done = is_done;
self.stopped_at = stopped_at;
Expand Down

0 comments on commit 513e7ad

Please sign in to comment.