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

No alloc #4

Merged
merged 3 commits into from
Apr 29, 2017
Merged

No alloc #4

merged 3 commits into from
Apr 29, 2017

Conversation

chpio
Copy link
Contributor

@chpio chpio commented Apr 29, 2017

Return a simple view instead of allocating a new string. It's a (partially) breaking change as the return type changes.

before:

test bench_gen_and_eq ... bench:          93 ns/iter (+/- 2)
test bench_write      ... bench:      11,200 ns/iter (+/- 396)

after:

test bench_gen_and_eq ... bench:          45 ns/iter (+/- 5)
test bench_write      ... bench:       5,018 ns/iter (+/- 166)

@Keruspe
Copy link
Contributor

Keruspe commented Apr 29, 2017

Can you rebase this please ?

@Keruspe
Copy link
Contributor

Keruspe commented Apr 29, 2017

Btw I think we shouldn't try to be too clever and just implement the default PartialEq + From<&str>

@chpio
Copy link
Contributor Author

chpio commented Apr 29, 2017

Can you rebase this please ?

yeap

Btw I think we shouldn't try to be too clever and just implement the default PartialEq + From<&str>

what do you mean by that? the PokemonUuid type should just implement a very small set of traits?

@Keruspe
Copy link
Contributor

Keruspe commented Apr 29, 2017 via email

@chpio
Copy link
Contributor Author

chpio commented Apr 29, 2017

are you referring to something like this one:

uuid_to_pokemon(u).into() == "foo bar"

uuid_to_pokemon returning a PokemonUuid and then converting it into a string?

@Keruspe
Copy link
Contributor

Keruspe commented Apr 29, 2017 via email

@chpio
Copy link
Contributor Author

chpio commented Apr 29, 2017

PokemonUuid::parse_str("foo bar").unwrap()

before (my 1. version):

test bench_eq      ... bench:       9,963 ns/iter (+/- 280)
test bench_eq_rand ... bench:       1,707 ns/iter (+/- 26)
test bench_write   ... bench:       4,965 ns/iter (+/- 97)

after:

test bench_eq      ... bench:       5,688 ns/iter (+/- 107)
test bench_eq_rand ... bench:       4,889 ns/iter (+/- 110)
test bench_write   ... bench:       5,059 ns/iter (+/- 179)

@Keruspe Keruspe merged commit 345f74f into CleverCloud:master Apr 29, 2017
@chpio
Copy link
Contributor Author

chpio commented Apr 29, 2017

shit, it wasn't done. i had to first fix it for incompatible lifetimes (the #[derive(PartialEq)] impl has only one lifetime, but we need two)

@chpio chpio deleted the no_alloc branch April 29, 2017 20:53
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.

2 participants