-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Adding Span IndexOfAny APIs that take 2 and 3 bytes #17357
Conversation
ebbbfdf
to
d542d83
Compare
I will be renaming these overloads to IndexOfAny. Is that fine? |
@terrajobst @ahsonkhan how are Span API additions reviewed? |
cc @KrzysztofCwalina, @shiftylogic, please take a look. |
@ahsonkhan how are the APIs in Span reviewed? (not code reviewed, but API-reviewed) |
@karelz, they were informally reviewed as part of the discussion that took place for dotnet/corefxlab#1292 @jkotas, @KrzysztofCwalina, @terrajobst, thoughts? |
@ahsonkhan Adding new APIs is documented at https://github.com/dotnet/corefx/blob/master/Documentation/project-docs/api-review-process.md . We should follow it for adding new Span APIs in corefx as well. |
Vector.BitwiseAnd( | ||
Vector.Equals(vData, values0), | ||
Vector.Equals(vData, values1)), | ||
Vector.Equals(vData, values2)); |
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.
nit: Spacing seems off
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.
I am not sure what the spacing should look like exactly, but made a change.
break; | ||
} | ||
index += Vector<byte>.Count; | ||
} while ((byte*) nLength > (byte*) index); |
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.
nit: remove spaces after casts.
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.
I think ReSharper/VS auto formatted to add those spaces. Will remove.
@dotnet-bot test Innerloop OSX10.12 Debug x64 Build and Test |
The API has been reviewed. Can this be merged now? |
We are still blocked on API approval as there have been further concerns: https://github.com/dotnet/corefx/issues/17414#issuecomment-289932452 @ahsonkhan let's not rush the API through please. I think we should wait on explicit green light from @KrzysztofCwalina and @jkotas on the API proposal. I am not sure if we have to do another API review next week. |
@karelz There are no concerns about this part of the API proposal. |
unchecked | ||
{ | ||
int unaligned = (int)(byte*)Unsafe.AsPointer(ref searchSpace) & (Vector<byte>.Count - 1); | ||
nLength = (IntPtr)(uint)unaligned; |
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.
Isn't this still backwards? If the purpose is to fix alignment, then you need to re-align the data on Vector.Count boundary. 'unaligned' above ends up being the number of bytes of misalignment. That would mean you need to advance Vector.Count - unaligned to get the data back into alignment.
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.
Yes, I will propagate the changes we made earlier:
#17500
unchecked | ||
{ | ||
int unaligned = (int)(byte*)Unsafe.AsPointer(ref searchSpace) & (Vector<byte>.Count - 1); | ||
nLength = (IntPtr)(uint)unaligned; |
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.
Same alignment issue as above.
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.
Ah yes, I will propagate the changes we made earlier:
#17500
Looks good. |
👍 |
@shiftylogic, good to go? |
From:
dotnet/corefxlab#1348 (comment)
Part of dotnet/corefxlab#1314 / dotnet/corefxlab#1293
Adding:
Edit: IndexOf => IndexOfAny
cc @KrzysztofCwalina, @davidfowl