@@ -6,11 +6,16 @@ namespace GitVersion.Git;
66internal sealed class CommitCollection : ICommitCollection
77{
88 private readonly ICommitLog innerCollection ;
9+ private readonly Lazy < IReadOnlyCollection < ICommit > > commits ;
910
10- internal CommitCollection ( ICommitLog collection ) => this . innerCollection = collection . NotNull ( ) ;
11+ internal CommitCollection ( ICommitLog collection )
12+ {
13+ this . innerCollection = collection . NotNull ( ) ;
14+ this . commits = new Lazy < IReadOnlyCollection < ICommit > > ( ( ) => this . innerCollection . Select ( commit => new Commit ( commit ) ) . ToArray ( ) ) ;
15+ }
1116
1217 public IEnumerator < ICommit > GetEnumerator ( )
13- => this . innerCollection . Select ( commit => new Commit ( commit ) ) . GetEnumerator ( ) ;
18+ => this . commits . Value . GetEnumerator ( ) ;
1419
1520 IEnumerator IEnumerable . GetEnumerator ( ) => GetEnumerator ( ) ;
1621
@@ -21,7 +26,13 @@ public IEnumerable<ICommit> QueryBy(CommitFilter commitFilter)
2126 {
2227 var includeReachableFrom = GetReacheableFrom ( commitFilter . IncludeReachableFrom ) ;
2328 var excludeReachableFrom = GetReacheableFrom ( commitFilter . ExcludeReachableFrom ) ;
24- var filter = new LibGit2Sharp . CommitFilter { IncludeReachableFrom = includeReachableFrom , ExcludeReachableFrom = excludeReachableFrom , FirstParentOnly = commitFilter . FirstParentOnly , SortBy = ( LibGit2Sharp . CommitSortStrategies ) commitFilter . SortBy } ;
29+ var filter = new LibGit2Sharp . CommitFilter
30+ {
31+ IncludeReachableFrom = includeReachableFrom ,
32+ ExcludeReachableFrom = excludeReachableFrom ,
33+ FirstParentOnly = commitFilter . FirstParentOnly ,
34+ SortBy = ( LibGit2Sharp . CommitSortStrategies ) commitFilter . SortBy
35+ } ;
2536 var commitLog = ( ( IQueryableCommitLog ) this . innerCollection ) . QueryBy ( filter ) ;
2637 return new CommitCollection ( commitLog ) ;
2738
0 commit comments