Showing the changes to git-commitgraph/src (3 of 4 files). Show all
Unified · Split
| @@ -46,7 +46,7 @@ impl File { · 45 unmodified lines | ||
| 46 | 46 | .try_into() |
| 47 | 47 | .expect("an architecture able to hold 32 bits of integer"); |
| 48 | 48 | let start = self.oid_lookup_offset + (pos * self.hash_len); |
| 49 | − git_hash::oid::try_from(&self.data[start..][..self.hash_len]).expect("hash bytes to be alright") | |
| 49 | + git_hash::oid::from_bytes_unchecked(&self.data[start..][..self.hash_len]) | |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | /// Return an iterator over all object hashes stored in the base graph. |
| @@ -55,7 +55,7 @@ impl File { · 2 unmodified lines | ||
| 55 | 55 | let base_graphs_list = &self.data[start..][..self.hash_len * usize::from(self.base_graph_count)]; |
| 56 | 56 | base_graphs_list |
| 57 | 57 | .chunks(self.hash_len) |
| 58 | − .map(|bytes| git_hash::oid::try_from(bytes).expect("hash bytes to be alright")) | |
| 58 | + .map(|bytes| git_hash::oid::from_bytes_unchecked(bytes)) | |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | /// return an iterator over all commits in this file. |
| @@ -43,7 +43,7 @@ impl<'a> Commit<'a> { · 42 unmodified lines | ||
| 43 | 43 | Commit { |
| 44 | 44 | file, |
| 45 | 45 | pos, |
| 46 | − root_tree_id: git_hash::oid::try_from(&bytes[..file.hash_len]).expect("hash bytes to be alright"), | |
| 46 | + root_tree_id: git_hash::oid::from_bytes_unchecked(&bytes[..file.hash_len]), | |
| 47 | 47 | parent1: ParentEdge::from_raw(BigEndian::read_u32(&bytes[file.hash_len..][..4])), |
| 48 | 48 | parent2: ParentEdge::from_raw(BigEndian::read_u32(&bytes[file.hash_len + 4..][..4])), |
| 49 | 49 | generation: BigEndian::read_u32(&bytes[file.hash_len + 8..][..4]) >> 2, |
| @@ -65,8 +65,7 @@ pub struct Outcome { · 64 unmodified lines | ||
| 65 | 65 | impl File { |
| 66 | 66 | /// Returns the trailing checksum over the entire content of this file. |
| 67 | 67 | pub fn checksum(&self) -> &git_hash::oid { |
| 68 | − git_hash::oid::try_from(&self.data[self.data.len() - self.hash_len..]) | |
| 69 | − .expect("file to be large enough for a hash") | |
| 68 | + git_hash::oid::from_bytes_unchecked(&self.data[self.data.len() - self.hash_len..]) | |
| 70 | 69 | } |
| 71 | 70 | |
| 72 | 71 | /// Traverse all [commits][file::Commit] stored in this file and call `processor(commit) -> Result<(), Error>` on it. |