Should keep practicing its usage so that this wonderful code multiplies.
Showing the changes to git-pack/src/data/input (2 of 6 files). Show all
Unified · Split
| @@ -61,13 +61,11 @@ where · 60 unmodified lines | ||
| 61 | 61 | had_error: false, |
| 62 | 62 | kind, |
| 63 | 63 | objects_left: num_objects, |
| 64 | − hash: if mode != input::Mode::AsIs { | |
| 64 | + hash: (mode != input::Mode::AsIs).then(|| { | |
| 65 | 65 | let mut hash = Sha1::default(); |
| 66 | 66 | hash.update(&header_data); |
| 67 | − Some(hash) | |
| 68 | − } else { | |
| 69 | − None | |
| 70 | − }, | |
| 67 | + hash | |
| 68 | + }), | |
| 71 | 69 | mode, |
| 72 | 70 | compressed_buf: None, |
| 73 | 71 | }) |
| @@ -149,11 +149,7 @@ where · 148 unmodified lines | ||
| 149 | 149 | self.inserted_entry_length_at_offset |
| 150 | 150 | .get(maybe_index_of_actual_entry) |
| 151 | 151 | .and_then(|c| { |
| 152 | − if c.pack_offset == base_pack_offset { | |
| 153 | − Some(maybe_index_of_actual_entry) | |
| 154 | − } else { | |
| 155 | − None | |
| 156 | − } | |
| 152 | + (c.pack_offset == base_pack_offset).then(|| maybe_index_of_actual_entry) | |
| 157 | 153 | }) |
| 158 | 154 | .unwrap_or(index) |
| 159 | 155 | }; |