-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement IEnumerator<T> on ref struct enumerators #106309
base: main
Are you sure you want to change the base?
Conversation
Note regarding the
|
1 similar comment
Note regarding the
|
src/libraries/System.Private.CoreLib/src/System/MemoryExtensions.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Text/SpanLineEnumerator.cs
Outdated
Show resolved
Hide resolved
@@ -222,7 +222,7 @@ public static void ValidateStrides(ReadOnlySpan<nint> strides, ReadOnlySpan<nint | |||
/// <param name="length">The length of the TensorSpan we are iterating over.</param> | |||
public static void AdjustIndexes(int curIndex, nint addend, Span<nint> curIndexes, scoped ReadOnlySpan<nint> length) | |||
{ | |||
if (addend <= 0 || curIndex < 0) | |||
if (addend <= 0 || curIndex < 0 || length[curIndex] <= 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's hitting this? Will this affect behavior of other public API?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It removes Access violation when length[curIndex] is zero. Now code throws an Access violation for an empty tensor.
That was incorrect behavior. I add tests for empty tensor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/ReadOnlyTensorSpan.cs
Show resolved
Hide resolved
.../System.Text.RegularExpressions/src/System/Text/RegularExpressions/Regex.EnumerateMatches.cs
Outdated
Show resolved
Hide resolved
Calling MoveNext after it's already returned false is a programmer error. It is not something we need to optimize for.
Close #105276