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

Question: Furthering use of Span<T> and ReadOnlySpan<T> with string manipulation. #27982

Closed
electricessence opened this issue Nov 22, 2018 · 4 comments

Comments

@electricessence
Copy link

I've noticed that the System.Text.RegularExpressions namespace is using Span for some processes.
And was thinking possibly a fundamental change is in order for string?

Operations like .Trim(), or even the .Value of Capture should return a ReadOnlySpan<char> or at least have exposed access like .AsSpan().

Thoughts?

@jkotas
Copy link
Member

jkotas commented Nov 22, 2018

cc @ViktorHofer

@ViktorHofer
Copy link
Member

Right there is room for optimization. There are a few ideas and a few open PRs. One i.e. will go into 3.0 as it's a low risk change and doesn't affect the internals of the existing engine too much: dotnet/corefx#32949.

There is another PR which changes the Interpreter to operate on Span instead which showed promising results but hadn't had time yet to refine it and fine a solution for the compiled side: ViktorHofer/corefx#3. This also contains the .Value change you mentioned.

@electricessence
Copy link
Author

I was thinking it possible to write an entire set of extensions around Span<char> like .Split() where but might be totally fine to use some of them completely flexible of value type.

@msftgits msftgits transferred this issue from dotnet/corefx Jan 31, 2020
@msftgits msftgits added this to the Future milestone Jan 31, 2020
@maryamariyan maryamariyan added the untriaged New issue has not been triaged by the area owner label Feb 23, 2020
@pgovind pgovind removed the untriaged New issue has not been triaged by the area owner label Jul 8, 2020
@stephentoub
Copy link
Member

Capture has a ValueSpan property in. NET 6, and in .NET 7 we've added span-based IsMatch and Count methods, and #65011 tracks additional span-based API on regex. Thanks.

@ghost ghost locked as resolved and limited conversation to collaborators Apr 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants