* It doesn't use evil `as`. * It's a bit less code. * It should be a tiny bit faster. * It is slightly more strict in that it will panic if the base graphs list is not evenly divisible into hashes. The file parser's error checking should ensure that this panic never happens, but maybe maybe maybe...
Showing the changes to git-commitgraph/src (1 of 1 file). Show all
Unified · Split
| @@ -42,12 +42,10 @@ impl File { · 41 unmodified lines | ||
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | pub fn iter_base_graph_ids(&self) -> impl Iterator<Item = borrowed::Id<'_>> { |
| 45 | − let base_graphs_list = match self.base_graphs_list_offset { | |
| 46 | − Some(v) => &self.data[v..v + (SHA1_SIZE * self.base_graph_count as usize)], | |
| 47 | − None => &[], | |
| 48 | − }; | |
| 45 | + let start = self.base_graphs_list_offset.unwrap_or(0); | |
| 46 | + let base_graphs_list = &self.data[start..start + (SHA1_SIZE * usize::from(self.base_graph_count))]; | |
| 49 | 47 | base_graphs_list |
| 50 | − .chunks_exact(SHA1_SIZE) | |
| 48 | + .chunks(SHA1_SIZE) | |
| 51 | 49 | .map(|bytes| borrowed::Id::try_from(bytes).expect("20 bytes SHA1 to be alright")) |
| 52 | 50 | } |
| 53 | 51 | |