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

Proposal: Span/Memory.Split #27667

Closed
schungx opened this issue Oct 18, 2018 · 1 comment
Closed

Proposal: Span/Memory.Split #27667

schungx opened this issue Oct 18, 2018 · 1 comment
Milestone

Comments

@schungx
Copy link

schungx commented Oct 18, 2018

Not sure if it is there already, but Split will be a great addition to Span/Memory, especially those related to char or byte.

Currently, String.Split creates multiple copies of sub-strings in an array. I can remember many times that I ended up rolling my own Split with IndexOf just to avoid creating large number of one-time strings in tight loops.

Adding Split to Span and Memory can alleviate all this, especially in common situations where:

  1. A string is split into multiple lines via \n
  2. Each line is split into multiple fields via white-space to extract a command and parameters
  3. Each command is processed individually

Both dotnet/corefx#1 and dotnet/corefx#2 above can be replaced by Span.Split which creates a simple array of a value type.

A further enhancement is to have Span.Split return a Span<Span<char>> to avoid creating the array.

@stephentoub
Copy link
Member

Thanks. Dup of https://github.com/dotnet/corefx/issues/26528.

@msftgits msftgits transferred this issue from dotnet/corefx Jan 31, 2020
@msftgits msftgits added this to the 3.0 milestone Jan 31, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants