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

Improve reverse of string. #353

Merged
merged 1 commit into from
Jun 7, 2017
Merged

Improve reverse of string. #353

merged 1 commit into from
Jun 7, 2017

Conversation

lrhn
Copy link
Contributor

@lrhn lrhn commented Jun 7, 2017

The existing implementation of reverse was quadratic in the string length.

It's still a very problematic method because it doesn't understand Unicode characters, only code points, so it will mis-attribute combining marks in a reversed string, e.g., reverse("niño") would become "õnin".

The existing implementation of reverse was quadratic in the string length.

It's still a very problematic method because it doesn't understand Unicode characters, only code points, so it will mis-attribute combining marks in a reversed string, e.g., reverse("niño") would become "õnin".
@jtmcdole
Copy link
Member

jtmcdole commented Jun 7, 2017

This looks like it still writes "õnin" if I put it in dartpad...

edit: I think that's what you were saying that the function is still problematic.

@jtmcdole
Copy link
Member

jtmcdole commented Jun 7, 2017

Failed dartfmt check: run dartfmt -w lib/ test/

Just run dartfmt again and it's LGTM by me.

@lrhn
Copy link
Contributor Author

lrhn commented Jun 7, 2017

Yes, it doesn't fix the inherent problem in the function (which is that it doesn't work for real-life text strings).
That would require a way to recognize grapheme clusters, not just code units.

@cbracken
Copy link
Member

cbracken commented Jun 7, 2017

Thanks! Filed #354 for the composed character ranges bug.

@cbracken cbracken merged commit b4a1cda into google:master Jun 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants