8000 Overkillest? · libgit2/libgit2sharp@c7c0e80 · GitHub
[go: up one dir, main page]

Skip to content

Commit c7c0e80

Browse files
committed
Overkillest?
Output from LibGit2Sharp.Tests.BranchFixture.Parents: Commits: 42000 Time: 2579 MaxParents: 8 Commits: 42000 Time: 2287 MaxParents: 8
1 parent 49ec181 commit c7c0e80

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

LibGit2Sharp/NewCommit.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,22 @@ namespace LibGit2Sharp
88
{
99
internal class ParentsList : IList<NewCommit>
1010
{
11-
private Lazy<IList<NewCommit>> parents;
12-
private Lazy<int> count;
11+
private readonly Lazy<IList<NewCommit>> _parents;
12+
private readonly Lazy<int> _count;
13+
1314
public ParentsList(Repository repo, NewCommit c)
1415
{
15-
parents = new Lazy<IList<NewCommit>>(() => RetrieveParentsOfCommit(repo, c.Id));
16-
count = new Lazy<int>(() => Proxy.git_commit_parentcount(repo.Handle, c.Id));
16+
_count = new Lazy<int>(() => Proxy.git_commit_parentcount(repo.Handle, c.Id));
17+
_parents = new Lazy<IList<NewCommit>>(() => RetrieveParentsOfCommit(repo, c.Id, _count));
1718
}
1819

19-
private IList<NewCommit> RetrieveParentsOfCommit(Repository repo, ObjectId oid)
20+
private IList<NewCommit> RetrieveParentsOfCommit(Repository repo, ObjectId oid, Lazy<int> pCount)
2021
{
2122
var parents = new List<NewCommit>();
2223

2324
using (var obj = new ObjectSafeWrapper(oid, repo.Handle))
2425
{
25-
int parentsCount = Proxy.git_commit_parentcount(obj);
26+
int parentsCount = pCount.Value;
2627

2728
for (uint i = 0; i < parentsCount; i++)
2829
{
@@ -71,7 +72,7 @@ public bool Remove(NewCommit item)
7172

7273
public int Count
7374
{
74-
get { return count.Value; }
75+
get { return _count.Value; }
7576
}
7677

7778
public bool IsReadOnly
@@ -96,7 +97,7 @@ public void RemoveAt(int index)
9697

9798
public NewCommit this[int index]
9899
{
99-
get { return parents.Value[index]; }
100+
get { return _parents.Value[index]; }
100101
set { throw new System.NotImplementedException(); }
101102
}
102103
}

0 commit comments

Comments
 (0)
0