#string #stack #inline #sso #inlinable

flexible-string

A stack heap flexible string designed to improve performance

1 unstable release

0.1.0 Jan 19, 2022

#2081 in Data structures

Download history 118/week @ 2023-12-27 93/week @ 2024-01-03 115/week @ 2024-01-10 74/week @ 2024-01-17 18/week @ 2024-01-24 114/week @ 2024-01-31 114/week @ 2024-02-07 2/week @ 2024-02-14 17/week @ 2024-02-21 13/week @ 2024-02-28 126/week @ 2024-03-06 7/week @ 2024-03-13 184/week @ 2024-03-20 75/week @ 2024-03-27 24/week @ 2024-04-03 76/week @ 2024-04-10

359 downloads per month
Used in spdlog-rs

MIT/Apache

50KB
610 lines

flexible-string

A stack heap flexible string designed to improve performance.

FlexibleString was first implemented in spdlog-rs crate, which improved performance for spdlog-rs by about double (see benchmarks of spdlog-rs). Now it is extracted to a separate crate for use by other crates.

For more details, please read the crate documentation.

Examples

You can use FlexibleString almost as well as standard String.

use flexible_string::FlexibleString;

let mut string = FlexibleString::<250>::from("hello");
string.push(',');
string.push_str("world");
assert_eq!(string, "hello,world");

Benchmarks

Run cargo +nightly bench in the root directory of this repository for benchmarking.

The following results are generated with Windows 10 64 bit and Intel i9-10900KF CPU @ 3.70GHz.

  • FlexibleString

    test bench_clone    ... bench:           7 ns/iter (+/- 0)
    test bench_from_str ... bench:           6 ns/iter (+/- 0)
    test bench_push     ... bench:           0 ns/iter (+/- 0)
    test bench_push_str ... bench:           0 ns/iter (+/- 0)
    
  • std::string::String

    test bench_clone    ... bench:          46 ns/iter (+/- 0)
    test bench_from_str ... bench:          40 ns/iter (+/- 0)
    test bench_push     ... bench:          41 ns/iter (+/- 0)
    test bench_push_str ... bench:          39 ns/iter (+/- 0)
    

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

No runtime deps