Skip to content

Commit aa596c9

Browse files
committed
attempt to fix performance issues with a cache
1 parent 9f8b337 commit aa596c9

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/GitVersion.LibGit2Sharp/Git/CommitCollection.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,16 @@ namespace GitVersion.Git;
66
internal 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

0 commit comments

Comments
 (0)