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

Conversions should not consume String #47

Closed
RReverser opened this issue Mar 6, 2017 · 1 comment
Closed

Conversions should not consume String #47

RReverser opened this issue Mar 6, 2017 · 1 comment

Comments

@RReverser
Copy link

Looks like most (all?) conversions create a new String, which means it should be sufficient for them to accept &str and not a String.

This way it would be possible to convert borrowed strings without cloning them (which is expensive due to extra temporary heap allocation and copying data).

@whatisinternet
Copy link
Owner

👍. I'd be interested in a PR if you're up for it. If not I'll have a look over the next few days.

@whatisinternet whatisinternet added this to the 0.9.0 milestone Mar 8, 2017
whatisinternet added a commit that referenced this issue Mar 10, 2017
* Changed from `String` to `&str` to gain extra speed and fewer allocations.

This moves the library to use `&str` as the input for most casting to
avoid the extra allocation required for `to_string()` or `to_owned()`.

Overall on local testing the benchmarks show a gain in every area.

* Updated version

* Updated changelog and readme to reflect changes

See #47

* Passed char as &char

* Updated readme with codecov

* Extra cargo meta-data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants