1
- using System . Collections ;
1
+ using System ;
2
+ using System . Collections ;
2
3
using System . Collections . Generic ;
3
4
using System . Diagnostics ;
4
5
using System . Globalization ;
@@ -14,7 +15,9 @@ namespace LibGit2Sharp
14
15
[ DebuggerDisplay ( "{DebuggerDisplay,nq}" ) ]
15
16
public class RefSpecCollection : IEnumerable < RefSpec >
16
17
{
17
- readonly IList < RefSpec > refspecs ;
18
+ readonly Remote remote ;
19
+ readonly RemoteSafeHandle handle ;
20
+ readonly Lazy < IList < RefSpec > > refspecs ;
18
21
19
22
/// <summary>
20
23
/// Needed for mocking purposes.
@@ -26,7 +29,10 @@ internal RefSpecCollection(Remote remote, RemoteSafeHandle handle)
26
29
{
27
30
Ensure . ArgumentNotNull ( handle , "handle" ) ;
28
31
29
- refspecs = RetrieveRefSpecs ( remote , handle ) ;
32
+ this . remote = remote ;
33
+ this . handle = handle ;
34
+
35
+ refspecs = new Lazy < IList < RefSpec > > ( ( ) => RetrieveRefSpecs ( remote , handle ) ) ;
30
36
}
31
37
32
38
static IList < RefSpec > RetrieveRefSpecs ( Remote remote , RemoteSafeHandle remoteHandle )
@@ -48,7 +54,7 @@ static IList<RefSpec> RetrieveRefSpecs(Remote remote, RemoteSafeHandle remoteHan
48
54
/// <returns>An <see cref="IEnumerator{T}"/> object that can be used to iterate through the collection.</returns>
49
55
public virtual IEnumerator < RefSpec > GetEnumerator ( )
50
56
{
51
- return refspecs . GetEnumerator ( ) ;
57
+ return refspecs . Value . GetEnumerator ( ) ;
52
58
}
53
59
54
60
/// <summary>
0 commit comments