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

A version of split that returns an array of substrings #3667

Closed
ViralBShah opened this issue Jul 10, 2013 · 6 comments
Closed

A version of split that returns an array of substrings #3667

ViralBShah opened this issue Jul 10, 2013 · 6 comments
Labels
performance Must go faster

Comments

@ViralBShah
Copy link
Member

I often find myself wanting an array of SubStrings rather than Strings as the output of split, in order to save memory and reduce GC pressure.

It would prefer to return an array of SubStrings by default, but I believe SubString indexing is slow (unsafe_view can help for now), and also any modifications to the SubStrings will get reflected in the original String (which I think is ok).

At the very least, I would propose to have splitsub.

@JeffBezanson
Copy link
Member

Modifying strings isn't really an issue since we don't support it.

@JeffBezanson
Copy link
Member

Could also fix #1250. For a string of type T, split giving an array of SubString{T} seems totally reasonable to me. @StefanKarpinski

@ViralBShah
Copy link
Member Author

Of course, just realized that we changed String to immutable. In that case, this seems even more reasonable to do. SubString indexing can be improved upon, I am sure.

@ViralBShah
Copy link
Member Author

Given the matchall implementation that @dcjones just did with SubStrings, and also the recent performance improvement in substring indexing, does it make sense to make split also return SubStrings? This is usually what I want.

For example, we could then use it in dlmread and simplify the code in there. Cc: @tanmaykm

@simonster
Copy link
Member

Is this fixed by #5451 / 1234340?

@quinnj
Copy link
Member

quinnj commented Jun 3, 2014

Bump, as @simonster, noted, I believe this is fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Must go faster
Projects
None yet
Development

No branches or pull requests

4 participants