@@ -8,21 +8,22 @@ namespace LibGit2Sharp
8
8
{
9
9
internal class ParentsList : IList < NewCommit >
10
10
{
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
+
13
14
public ParentsList ( Repository repo , NewCommit c )
14
15
{
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 ) ) ;
17
18
}
18
19
19
- private IList < NewCommit > RetrieveParentsOfCommit ( Repository repo , ObjectId oid )
20
+ private IList < NewCommit > RetrieveParentsOfCommit ( Repository repo , ObjectId oid , Lazy < int > pCount )
20
21
{
21
22
var parents = new List < NewCommit > ( ) ;
22
23
23
24
using ( var obj = new ObjectSafeWrapper ( oid , repo . Handle ) )
24
25
{
25
- int parentsCount = Proxy . git_commit_parentcount ( obj ) ;
26
+ int parentsCount = pCount . Value ;
26
27
27
28
for ( uint i = 0 ; i < parentsCount ; i ++ )
28
29
{
@@ -71,7 +72,7 @@ public bool Remove(NewCommit item)
71
72
72
73
public int Count
73
74
{
74
- get { return count . Value ; }
75
+ get { return _count . Value ; }
75
76
}
76
77
77
78
public bool IsReadOnly
@@ -96,7 +97,7 @@ public void RemoveAt(int index)
96
97
97
98
public NewCommit this [ int index ]
98
99
{
99
- get { return parents . Value [ index ] ; }
100
+ get { return _parents . Value [ index ] ; }
100
101
set { throw new System . NotImplementedException ( ) ; }
101
102
}
102
103
}
0 commit comments