fitzgen / inlinable_string

An owned, grow-able UTF-8 string that stores small strings inline and avoids heap-allocation.
http://fitzgen.github.io/inlinable_string/inlinable_string/index.html
Other
69 stars 11 forks source link

Remove need for bare-io by using encode_utf8 #35

Closed 5225225 closed 2 years ago

5225225 commented 2 years ago

Fixes #34

This makes the no_std feature completely obsolete, but it needs to be kept for compatibility (unless a major version bump is done).

There shouldn't be any MSRV concerns as encode_utf8 was stable in 1.15, the MSRV for this crate is at least 1.31 since it uses edition 2018.

5225225 commented 2 years ago

Ran the benchmarks (once)

Before:

test benches::bench_inlinable_string_from_large                ... bench:          33 ns/iter (+/- 2)
test benches::bench_inlinable_string_from_small                ... bench:           2 ns/iter (+/- 0)
test benches::bench_inlinable_string_push_str_large_onto_empty ... bench:          44 ns/iter (+/- 1)
test benches::bench_inlinable_string_push_str_large_onto_large ... bench:         146 ns/iter (+/- 3)
test benches::bench_inlinable_string_push_str_small_onto_empty ... bench:           2 ns/iter (+/- 0)
test benches::bench_inlinable_string_push_str_small_onto_small ... bench:          10 ns/iter (+/- 0)
test benches::bench_std_string_from_large                      ... bench:          32 ns/iter (+/- 2)
test benches::bench_std_string_from_small                      ... bench:          13 ns/iter (+/- 0)
test benches::bench_std_string_push_str_large_onto_empty       ... bench:          41 ns/iter (+/- 0)
test benches::bench_std_string_push_str_large_onto_large       ... bench:         148 ns/iter (+/- 3)
test benches::bench_std_string_push_str_small_onto_empty       ... bench:          24 ns/iter (+/- 0)
test benches::bench_std_string_push_str_small_onto_small       ... bench:          39 ns/iter (+/- 1)
test inline_string::benches::its_fast                          ... bench:           0 ns/iter (+/- 0)

After:

test benches::bench_inlinable_string_from_large                ... bench:          33 ns/iter (+/- 1)
test benches::bench_inlinable_string_from_small                ... bench:           2 ns/iter (+/- 0)
test benches::bench_inlinable_string_push_str_large_onto_empty ... bench:          44 ns/iter (+/- 0)
test benches::bench_inlinable_string_push_str_large_onto_large ... bench:         147 ns/iter (+/- 3)
test benches::bench_inlinable_string_push_str_small_onto_empty ... bench:           2 ns/iter (+/- 0)
test benches::bench_inlinable_string_push_str_small_onto_small ... bench:          10 ns/iter (+/- 0)
test benches::bench_std_string_from_large                      ... bench:          31 ns/iter (+/- 1)
test benches::bench_std_string_from_small                      ... bench:          13 ns/iter (+/- 0)
test benches::bench_std_string_push_str_large_onto_empty       ... bench:          36 ns/iter (+/- 2)
test benches::bench_std_string_push_str_large_onto_large       ... bench:         150 ns/iter (+/- 2)
test benches::bench_std_string_push_str_small_onto_empty       ... bench:          18 ns/iter (+/- 1)
test benches::bench_std_string_push_str_small_onto_small       ... bench:          29 ns/iter (+/- 1)
test inline_string::benches::its_fast                          ... bench:           0 ns/iter (+/- 0)

I have no idea what that bench_std_string_push_str_small_onto_small difference means.

ArtemGr commented 2 years ago

Thanks! Would you bump to version = "0.1.15"?

5225225 commented 2 years ago

There's also a miri failure when running with -Zmiri-tag-raw-pointers, so I'd ideally get that fixed before a release. I'll make a different branch for that (based off this PR because I can't get the code to build without it).

5225225 commented 2 years ago

Scratch that, I'll just make the fix here, it shouldn't be too major.

ArtemGr commented 2 years ago

Awesome!

ArtemGr commented 2 years ago

In case somebody's looking for bare-io, looks like it has been renamed to core2, https://github.com/technocreatives/core2/commit/4072d2a09ba0d656571b1cd2ef6d95aa575c4a69.