8000 Add Count property, skip enumeration when only # of changes is important · libgit2/libgit2sharp@c37b48e · GitHub
[go: up one dir, main page]

Skip to content

Commit c37b48e

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

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

LibGit2Sharp/TreeChanges.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ internal unsafe TreeChanges(DiffHandle diff)
3939
private IEnumerable<TreeEntryChanges> GetChangesOfKind(ChangeKind changeKind)
4040
{
4141
TreeEntryChanges entry;
42-
43-
for (int i = 0; i < count.Value; i++)
42+
for (int i = 0; i < Count; i++)
4443
{
4544
if (TryGetEntryWithChangeTypeAt(i, changeKind, out entry))
4645
{
@@ -78,7 +77,7 @@ private unsafe bool TryGetEntryWithChangeTypeAt(int index, ChangeKind changeKind
7877
/// <returns>An <see cref="IEnumerator{T}"/> object that can be used to iterate through the collection.</returns>
7978
public virtual IEnumerator<TreeEntryChanges> GetEnumerator()
8079
{
81-
for (int i = 0; i < count.Value; i++)
80+
for (int i = 0; i < Count; i++)
8281
{
8382
yield return GetEntryAt(i);
8483
}
@@ -171,6 +170,14 @@ public virtual IEnumerable<TreeEntryChanges> Conflicted
171170
get { return GetChangesOfKind(ChangeKind.Conflicted); }
172171
}
173172

173+
/// <summary>
174+
/// Gets the number of <see cref="TreeEntryChanges"/> in this comparison.
175+
/// </summary>
176+
public virtual int Count
177+
{
178+
get { return count.Value; }
179+
}
180+
174181
private string DebuggerDisplay
175182
{
176183
get

0 commit comments

Comments
 (0)
0