Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Adding Span LastIndexOfAny APIs and tests#25848

Merged
ahsonkhan merged 4 commits into
dotnet:masterfrom
ahsonkhan:LastIndexOfAny
Dec 13, 2017
Merged

Adding Span LastIndexOfAny APIs and tests#25848
ahsonkhan merged 4 commits into
dotnet:masterfrom
ahsonkhan:LastIndexOfAny

Conversation

@ahsonkhan
Copy link
Copy Markdown

@ahsonkhan
Copy link
Copy Markdown
Author

Is this PR good to merge?

@dotnet-bot test Linux x64 Release Build

IntPtr index = (IntPtr)(uint)length; // Use UIntPtr for arithmetic to avoid unnecessary 64->32->64 truncations
IntPtr nLength = (IntPtr)(uint)length;
#if !netstandard11
if (Vector.IsHardwareAccelerated && length >= Vector<byte>.Count * 2)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some more comments in this code would be useful.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I won't block on this (since CI is green), but will keep a note of this, especially if we were to re-work some of the implementation details.

if ((int)(byte*)index > 0)
{
nLength = index;
goto SequentialScan;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you go to sequential scan from here, after finishing the sequential scan, you will execute if (Vector.IsHardwareAccelerated && ((int)(byte*)index > 0)) gain, which will never evaluate to true, i.e. you will execute the check twice. Is this the best way to organize the code?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are right. Good catch!

We should consider looking at all the {Last}IndexOf vectorized APIs together and see if we can optimize it further since such issues exist in existing implementation too.

I had discussed this previously with Levi. I will file an issue.

cc @GrabYourPitchforks

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ahsonkhan ahsonkhan merged commit c20881a into dotnet:master Dec 13, 2017
@ahsonkhan ahsonkhan deleted the LastIndexOfAny branch December 13, 2017 19:29
@karelz karelz added this to the 2.1.0 milestone Dec 28, 2017
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
* Adding LastIndexOfAny APIs and tests.

* Adding ReadOnlySpan LastIndexOfAny tests.

* Remove service property from test project

* Remove service property from performance test project


Commit migrated from dotnet/corefx@c20881a
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants