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

CallSites for MemoryExtensions.Contains (CoreCLR) #19874

Merged
merged 4 commits into from
Sep 12, 2018

Conversation

grant-d
Copy link

@grant-d grant-d commented Sep 8, 2018

Copy link

@ahsonkhan ahsonkhan left a comment

Choose a reason for hiding this comment

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

Missed one:

Otherwise, LGTM. Thanks :)

@grant-d
Copy link
Author

grant-d commented Sep 8, 2018

@ahsonkhan, not sure what you are proposing with that one - it is an instance method on string, and delegates to string.IndexOf not Span<T>.IndexOf. Unless you are proposing I use string.AsSpan<char>.Contains?

@ahsonkhan
Copy link

Unless you are proposing I use string.AsSpan<char>.Contains?

No, that isn't what I was suggesting.

not sure what you are proposing with that one - it is an instance method on string, and delegates to string.IndexOf not Span<T>.IndexOf

Right now public bool Contains(char value) is calling the following, which ends up calling the SpanHelpers static method:

public int IndexOf(char value) => SpanHelpers.IndexOf(ref _firstChar, value, Length);

Is it possible for it to instead call the following, directly?

public static unsafe bool Contains(ref char searchSpace, char value, int length)

So, something like:

        public bool Contains(char value) => SpanHelpers.Contains(ref _firstChar, value, Length);

@grant-d
Copy link
Author

grant-d commented Sep 8, 2018

Sorry, must be a Friday, that makes sense.
PR updated.

@grant-d grant-d changed the title Update CallSites for MemoryExtensions.Contains Update CallSites for MemoryExtensions.Contains (CoreCLR) Sep 8, 2018
@grant-d grant-d changed the title Update CallSites for MemoryExtensions.Contains (CoreCLR) Update CallSites for MemoryExtensions.Contains (coreclr) Sep 8, 2018
@ahsonkhan
Copy link

@dotnet-bot test Ubuntu x64 Checked CoreFX Tests

1 similar comment
@jkotas
Copy link
Member

jkotas commented Sep 8, 2018

@dotnet-bot test Ubuntu x64 Checked CoreFX Tests

@grant-d
Copy link
Author

grant-d commented Sep 11, 2018

@ahsonkhan would you mind taking another look at this, I have added a couple more call sites since your previous approval so it would be great if you could confirm it's kosher (& hopefully merge it)?

@grant-d grant-d changed the title Update CallSites for MemoryExtensions.Contains (coreclr) Update CallSites for MemoryExtensions.Contains (CoreCLR) Sep 12, 2018
@grant-d grant-d changed the title Update CallSites for MemoryExtensions.Contains (CoreCLR) CallSites for MemoryExtensions.Contains (CoreCLR) Sep 12, 2018
@ahsonkhan ahsonkhan merged commit 9d8d00c into dotnet:master Sep 12, 2018
dotnet-maestro-bot pushed a commit to dotnet-maestro-bot/corefx that referenced this pull request Sep 12, 2018
* Update additional callsites for MemoryExtensions.Contains

* One more callsite

* More callsites

* CR fixes

Signed-off-by: dotnet-bot <[email protected]>
dotnet-maestro-bot pushed a commit to dotnet-maestro-bot/corert that referenced this pull request Sep 12, 2018
* Update additional callsites for MemoryExtensions.Contains

* One more callsite

* More callsites

* CR fixes

Signed-off-by: dotnet-bot <[email protected]>
@grant-d grant-d deleted the MemoryExtensions.Contains2 branch September 12, 2018 11:06
jkotas pushed a commit to dotnet/corert that referenced this pull request Sep 12, 2018
* Update additional callsites for MemoryExtensions.Contains

* One more callsite

* More callsites

* CR fixes

Signed-off-by: dotnet-bot <[email protected]>
jkotas pushed a commit to dotnet/corefx that referenced this pull request Sep 12, 2018
* Update additional callsites for MemoryExtensions.Contains

* One more callsite

* More callsites

* CR fixes

Signed-off-by: dotnet-bot <[email protected]>
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