History

thanks clippy

Sebastian Thiel committed 5 years ago

Commit 6200ed91 parent 217451320 files · +52 −50Browse files

Showing the changes to git-pack/src/data (6 of 20 files). Show all

Unified · Split

6 files
  1. git-pack/src/data/entry/header.rs +4 −4
  2. git-pack/src/data/entry/mod.rs +1 −1
  3. git-pack/src/data/file/decode_entry.rs +2 −2
  4. git-pack/src/data/input/iter.rs +1 −1
  5. git-pack/src/data/output/bytes.rs +1 −1
  6. git-pack/src/data/output/entry/mod.rs +1 −1
git-pack/src/data/entry/header.rs+4−4
@@ -44,7 +44,7 @@ impl Header { · 43 unmodified lines
4444 pack_offset.checked_sub(distance)
4545 }
4646 /// Convert the header's object kind into [`git_object::Kind`] if possible
47− pub fn to_kind(&self) -> Option<git_object::Kind> {
47+ pub fn as_kind(&self) -> Option<git_object::Kind> {
4848 use git_object::Kind::*;
4949 Some(match self {
5050 Header::Tree => Tree,
@@ -55,7 +55,7 @@ impl Header { · 4 unmodified lines
5555 })
5656 }
5757 /// Convert this header's object kind into the packs internal representation
58− pub fn to_type_id(&self) -> u8 {
58+ pub fn as_type_id(&self) -> u8 {
5959 use Header::*;
6060 match self {
6161 Blob => BLOB,
@@ -81,10 +81,10 @@ impl Header { · 19 unmodified lines
8181 ///
8282 /// Returns the amount of bytes written to `out`.
8383 /// `decompressed_size_in_bytes` is the full size in bytes of the object that this header represents
84− pub fn to_write(&self, decompressed_size_in_bytes: u64, mut out: impl io::Write) -> io::Result<usize> {
84+ pub fn write_to(&self, decompressed_size_in_bytes: u64, mut out: impl io::Write) -> io::Result<usize> {
8585 let mut size = decompressed_size_in_bytes;
8686 let mut written = 1;
87− let mut c: u8 = (self.to_type_id() << 4) | (size as u8 & 0b0000_1111);
87+ let mut c: u8 = (self.as_type_id() << 4) | (size as u8 & 0b0000_1111);
8888 size >>= 4;
8989 while size != 0 {
9090 out.write_all(&[c | 0b1000_0000])?;
git-pack/src/data/entry/mod.rs+1−1
@@ -36,7 +36,7 @@ impl Entry { · 35 unmodified lines
3636 /// The amount of bytes used to describe this entry in the pack. The header starts at [`Self::pack_offset()`]
3737 pub fn header_size(&self) -> usize {
3838 self.header
39− .to_write(self.decompressed_size, io::sink())
39+ .write_to(self.decompressed_size, io::sink())
4040 .expect("io::sink() to never fail")
4141 }
4242 }
git-pack/src/data/file/decode_entry.rs+2−2
@@ -153,7 +153,7 @@ impl File { · 152 unmodified lines
153153 );
154154 self.decompress_entry(&entry, out.as_mut_slice()).map(|consumed_input| {
155155 Outcome::from_object_entry(
156− entry.header.to_kind().expect("a non-delta entry"),
156+ entry.header.as_kind().expect("a non-delta entry"),
157157 &entry,
158158 consumed_input,
159159 )
@@ -314,7 +314,7 @@ impl File { · 154 unmodified lines
314314 if base_buffer_size.is_none() {
315315 let base_entry = cursor;
316316 debug_assert!(!base_entry.header.is_delta());
317− object_kind = base_entry.header.to_kind();
317+ object_kind = base_entry.header.as_kind();
318318 let packed_size = self.decompress_entry_from_data_offset(base_entry.data_offset, out)?;
319319 cache.put(
320320 self.id,
git-pack/src/data/input/iter.rs+1−1
@@ -138,7 +138,7 @@ where · 137 unmodified lines
138138
139139 let crc32 = if self.compressed.crc32() {
140140 let mut header_buf = [0u8; 32];
141− let header_len = entry.header.to_write(bytes_copied, header_buf.as_mut())?;
141+ let header_len = entry.header.write_to(bytes_copied, header_buf.as_mut())?;
142142 let state = git_features::hash::crc32_update(0, &header_buf[..header_len]);
143143 Some(git_features::hash::crc32_update(state, &compressed))
144144 } else {
git-pack/src/data/output/bytes.rs+1−1
@@ -100,7 +100,7 @@ where · 99 unmodified lines
100100 let header = entry.to_entry_header(self.entry_version, |_index_offset| {
101101 unimplemented!("a way to calculate pack offsets from object index offsets")
102102 });
103− written += header.to_write(entry.decompressed_size as u64, &mut self.output)? as u64;
103+ written += header.write_to(entry.decompressed_size as u64, &mut self.output)? as u64;
104104 written += std::io::copy(&mut &*entry.compressed_data, &mut self.output)? as u64;
105105 }
106106 }
git-pack/src/data/output/entry/mod.rs+1−1
@@ -80,7 +80,7 @@ impl output::Entry { · 79 unmodified lines
8080 if pack_entry.header.is_base() {
8181 Some(Ok(output::Entry {
8282 id: count.id.to_owned(),
83− object_kind: pack_entry.header.to_kind().expect("valid object only"),
83+ object_kind: pack_entry.header.as_kind().expect("valid object only"),
8484 kind: output::entry::Kind::Base,
8585 decompressed_size: pack_entry.decompressed_size as usize,
8686 compressed_data: entry.data[pack_entry.data_offset as usize..].to_owned(),