Skip to content

Commit

Permalink
attempt to fix performance issues with a cache
Browse files Browse the repository at this point in the history
  • Loading branch information
arturcic committed Oct 9, 2024
1 parent 9f8b337 commit aa596c9
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/GitVersion.LibGit2Sharp/Git/CommitCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@ namespace GitVersion.Git;
internal sealed class CommitCollection : ICommitCollection
{
private readonly ICommitLog innerCollection;
private readonly Lazy<IReadOnlyCollection<ICommit>> commits;

internal CommitCollection(ICommitLog collection) => this.innerCollection = collection.NotNull();
internal CommitCollection(ICommitLog collection)
{
this.innerCollection = collection.NotNull();
this.commits = new Lazy<IReadOnlyCollection<ICommit>>(() => this.innerCollection.Select(commit => new Commit(commit)).ToArray());
}

public IEnumerator<ICommit> GetEnumerator()
=> this.innerCollection.Select(commit => new Commit(commit)).GetEnumerator();
=> this.commits.Value.GetEnumerator();

IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();

Expand Down

0 comments on commit aa596c9

Please sign in to comment.