Skip to content

Commit

Permalink
better var names
Browse files Browse the repository at this point in the history
  • Loading branch information
fafhrd91 committed Jul 26, 2018
1 parent d916363 commit 92a798f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/gz/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@ pub struct GzDecoder<W: Write> {
header: Option<GzHeader>,
}

const CRC_BYTES_LEN: usize = 8;

impl<W: Write> GzDecoder<W> {
/// Creates a new decoder which will write uncompressed data to the stream.
///
Expand All @@ -230,7 +232,7 @@ impl<W: Write> GzDecoder<W> {
pub fn new(w: W) -> GzDecoder<W> {
GzDecoder {
inner: zio::Writer::new(CrcWriter::new(w), Decompress::new(false)),
crc_bytes: Vec::with_capacity(8),
crc_bytes: Vec::with_capacity(CRC_BYTES_LEN),
header: None,
}
}
Expand Down Expand Up @@ -317,9 +319,10 @@ impl<W: Write> GzDecoder<W> {

if status == Status::StreamEnd {
if n < buf.len() && self.crc_bytes.len() < 8 {
let d = cmp::min(buf.len(), n + 8 - self.crc_bytes.len());
self.crc_bytes.extend(&buf[n..d]);
return Ok(d)
let remaining = buf.len() - n;
let crc_bytes = cmp::min(remaining, CRC_BYTES_LEN - self.crc_bytes.len());
self.crc_bytes.extend(&buf[n..n+crc_bytes]);
return Ok(n+crc_bytes)
}
}
Ok(n)
Expand Down

0 comments on commit 92a798f

Please sign in to comment.