Skip to content
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

MemoryMarshal.IndexOfAny/LastIndexOfAny for non-primitives does not special-case small needle spans #53655

Open
GrabYourPitchforks opened this issue Jun 3, 2021 · 1 comment
Labels
Milestone

Comments

@GrabYourPitchforks
Copy link
Member

Based on a conversation at #53652 (comment).

In the implementation of MemoryExtensions.IndexOfAny<T>(ROS<T>, ROS<T>) [see code], small needle spans are special-cased for T=byte and T=char and sent to specialized helpers in SpanHelpers. But for any other T, these small needle spans are not special-cased, and control flow goes to the generalized SpanHelpers.IndexOfAny<T>(ref T, int, ref T, int) routine, even though n-ary specialized helpers exist.

We should consider special-casing these lengths within the MemoryExtensions.IndexOfAny and LastIndexOfAny methods and funneling to the specialized n-ary helpers. Or, if there's a specific reason this logic was left out for non-byte / non-char types T, we should put a comment in the code to clarify why this logic has been excluded.

@ghost
Copy link

ghost commented Jun 3, 2021

Tagging subscribers to this area: @GrabYourPitchforks, @carlossanlop
See info in area-owners.md if you want to be subscribed.

Issue Details

Based on a conversation at #53652 (comment).

In the implementation of MemoryExtensions.IndexOfAny<T>(ROS<T>, ROS<T>) [see code], small needle spans are special-cased for T=byte and T=char and sent to specialized helpers in SpanHelpers. But for any other T, these small needle spans are not special-cased, and control flow goes to the generalized SpanHelpers.IndexOfAny<T>(ref T, int, ref T, int) routine, even though n-ary specialized helpers exist.

We should consider special-casing these lengths within the MemoryExtensions.IndexOfAny and LastIndexOfAny methods and funneling to the specialized n-ary helpers. Or, if there's a specific reason this logic was left out for non-byte / non-char types T, we should put a comment in the code to clarify why this logic has been excluded.

Author: GrabYourPitchforks
Assignees: -
Labels:

area-System.Memory, tenet-performance

Milestone: -

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged New issue has not been triaged by the area owner label Jun 3, 2021
@jeffhandley jeffhandley added this to the Future milestone Jul 13, 2021
@jeffhandley jeffhandley removed the untriaged New issue has not been triaged by the area owner label Jul 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants