Skip to content

Commit f44d727

Browse files
committed
Add Count property, skip enumeration when only # of changes is important
1 parent 1f3d7b7 commit f44d727

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

LibGit2Sharp/TreeChanges.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ internal TreeChanges(DiffSafeHandle diff)
3838
/// <param name="changeKind">Change type to filter on.</param>
3939
private IEnumerable<TreeEntryChanges> GetChangesOfKind(ChangeKind changeKind)
4040
{
41-
for (int i = 0; i < count.Value; i++)
41+
for (int i = 0; i < Count; i++)
4242
{
4343
var delta = Proxy.git_diff_get_delta(diff, i);
4444

@@ -60,7 +60,7 @@ private static TreeEntryChanges ToTreeEntryChange(GitDiffDelta delta)
6060
/// <returns>An <see cref="IEnumerator{T}"/> object that can be used to iterate through the collection.</returns>
6161
public virtual IEnumerator<TreeEntryChanges> GetEnumerator()
6262
{
63-
for (int i = 0; i < count.Value; i++)
63+
for (int i = 0; i < Count; i++)
6464
{
6565
yield return new TreeEntryChanges(Proxy.git_diff_get_delta(diff, i));
6666
}
@@ -141,6 +141,14 @@ public virtual IEnumerable<TreeEntryChanges> Conflicted
141141
get { return GetChangesOfKind(ChangeKind.Conflicted); }
142142
}
143143

144+
/// <summary>
145+
/// Gets the number of <see cref="TreeEntryChanges"/> in this comparison.
146+
/// </summary>
147+
public virtual int Count
148+
{
149+
get { return count.Value; }
150+
}
151+
144152
private string DebuggerDisplay
145153
{
146154
get

0 commit comments

Comments
 (0)