Skip to content

Commit 79b476d

Browse files
committed
[Array] improve visit
1 parent 6e3255c commit 79b476d

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/StructLinq/Array/ArrayEnumerable.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,18 @@ public T Get(int i)
5757
public VisitStatus Visit<TVisitor>(ref TVisitor visitor)
5858
where TVisitor : IVisitor<T>
5959
{
60-
var count = Count;
61-
var s = start;
62-
for (int i = 0; i < count; i++)
60+
unchecked
6361
{
64-
if (!visitor.Visit(array[s+i]))
65-
return VisitStatus.VisitorFinished;
66-
}
62+
var s = start;
63+
var end = Count + s;
64+
for (int i = s; i < end; i++)
65+
{
66+
if (!visitor.Visit(array[i]))
67+
return VisitStatus.VisitorFinished;
68+
}
6769

68-
return VisitStatus.EnumeratorFinished;
70+
return VisitStatus.EnumeratorFinished;
71+
}
6972
}
7073
}
7174
}

0 commit comments

Comments
 (0)