History

[hours-demo] Maybe the pinnacle of performance…

…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.

Sebastian Thiel committed 5 years ago

Commit f70c61a1 parent eed481e3 files · +47 −10Browse files

Showing the changes to git-object/src/immutable/commit.rs (1 of 3 files). Show all

Unified · Split

git-object/src/immutable/commit.rs+28−4
@@ -186,6 +186,20 @@ pub mod iter { · 185 unmodified lines
186186 pub fn tree_id(&mut self) -> Option<ObjectId> {
187187 self.next().and_then(Result::ok).and_then(Token::into_id)
188188 }
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+ }
189203 }
190204
191205 impl<'a> Iter<'a> {
@@ -305,10 +319,20 @@ pub mod iter { · 113 unmodified lines
305319 #[allow(missing_docs)]
306320 #[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)]
307321 pub enum Token<'a> {
308− Tree { id: ObjectId },
309− Parent { id: ObjectId },
310− Author { signature: Signature<'a> },
311− Committer { signature: Signature<'a> },
322+ Tree {
323+ id: ObjectId,
324+ },
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+ },
312336 Encoding(&'a BStr),
313337 ExtraHeader((&'a BStr, Cow<'a, BStr>)),
314338 Message(&'a BStr),

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t