…and up from about * 750k commits/s for accessing and fully decoding the commit twice * 2.4mio commits/s for storing the data during iteration and decoding it fully * 3.0mio commits/s for storing the data during iteration and decoding it only to the author signature.
Showing the changes to git-object/src/immutable/commit.rs (1 of 3 files). Show all
Unified · Split
| @@ -186,6 +186,20 @@ pub mod iter { · 185 unmodified lines | |||
| 186 | pub fn tree_id(&mut self) -> Option<ObjectId> { | 186 | pub fn tree_id(&mut self) -> Option<ObjectId> { |
| 187 | self.next().and_then(Result::ok).and_then(Token::into_id) | 187 | self.next().and_then(Result::ok).and_then(Token::into_id) |
| 188 | } | 188 | } |
| 189 | |||
| 190 | /// Returns all signatures, first the author, then the committer, if there is no decoding error. | ||
| 191 | /// | ||
| 192 | /// Errors are coerced into options, hiding whether there was an error or not. The caller knows if there was an error or not | ||
| 193 | /// if not exactly two signatures were iterable. | ||
| 194 | /// Errors are not the common case - if an error needs to be detectable, use this instance as iterator. | ||
| 195 | pub fn signatures(&'a mut self) -> impl Iterator<Item = Signature<'_>> + 'a { | ||
| 196 | self.filter_map(Result::ok) | ||
| 197 | .skip_while(|t| !matches!(t, Token::Author { .. } | Token::Committer { .. })) | ||
| 198 | .filter_map(|t| match t { | ||
| 199 | Token::Author { signature } | Token::Committer { signature } => Some(signature), | ||
| 200 | _ => None, | ||
| 201 | }) | ||
| 202 | } | ||
| 189 | } | 203 | } |
| 190 | 204 | ||
| 191 | impl<'a> Iter<'a> { | 205 | impl<'a> Iter<'a> { |
| @@ -305,10 +319,20 @@ pub mod iter { · 113 unmodified lines | |||
| 305 | #[allow(missing_docs)] | 319 | #[allow(missing_docs)] |
| 306 | #[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)] | 320 | #[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)] |
| 307 | pub enum Token<'a> { | 321 | pub enum Token<'a> { |
| 308 | Tree { id: ObjectId }, | 322 | Tree { |
| 309 | Parent { id: ObjectId }, | 323 | id: ObjectId, |
| 310 | Author { signature: Signature<'a> }, | 324 | }, |
| 311 | Committer { signature: Signature<'a> }, | 325 | Parent { |
| 326 | id: ObjectId, | ||
| 327 | }, | ||
| 328 | /// A person who authored the content of the commit. | ||
| 329 | Author { | ||
| 330 | signature: Signature<'a>, | ||
| 331 | }, | ||
| 332 | /// A person who committed the authors work to the repository. | ||
| 333 | Committer { | ||
| 334 | signature: Signature<'a>, | ||
| 335 | }, | ||
| 312 | Encoding(&'a BStr), | 336 | Encoding(&'a BStr), |
| 313 | ExtraHeader((&'a BStr, Cow<'a, BStr>)), | 337 | ExtraHeader((&'a BStr, Cow<'a, BStr>)), |
| 314 | Message(&'a BStr), | 338 | Message(&'a BStr), |