Stack heap flexible string designed to improve performance for Rust

Overview

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.

You might also like...
Idiomatic Rust implementations for various Windows string types (like UNICODE_STRING)
Idiomatic Rust implementations for various Windows string types (like UNICODE_STRING)

nt-string by Colin Finck [email protected] Provides idiomatic Rust implementations for various Windows string types: NtUnicodeString (with NtUnicode

Rust based magic-string with source map chains support

enhanced-magic-string Rust implementation of https://www.npmjs.com/package/magic-string with original sourcemap chain support. license. This project i

Simple string matching with questionmark- and star-wildcard operator

wildmatch Match strings against a simple wildcard pattern. Tests a wildcard pattern p against an input string s. Returns true only when p matches the

A crate for converting an ASCII text string or file to a single unicode character

A crate for converting an ASCII text string or file to a single unicode character. Also provides a macro to embed encoded source code into a Rust source file. Can also do the same to Python code while still letting the code run as before by wrapping it in a decoder.

Compact, clone-on-write vector and string.

ecow Compact, clone-on-write vector and string. Types An EcoVec is a reference-counted clone-on-write vector. It takes up two words of space (= 2 usiz

Parses a relative time string and returns a `Duration`

humantime_to_duration A Rust crate for parsing human-readable relative time strings and converting them to a Duration. Features Parses a variety of hu

How to be a full stack Rust Developer
How to be a full stack Rust Developer

How to be a full stack Rust Developer Read Rust API guideline. Test code here and refer to the Rust blog posts at Steadylearner. If you need or know s

A stack based, virtual machine language written in Rust

Stackyy A stack based, virtual machine language written in Rust Description: Stackyy is a stack based, virtual machine language inspired by Forth and

An MVP stack based bytecode VM

TinyVM An MVP stack-based bytecode VM This VM runs a simplistic, Turing complete instruction set. In ~250 LOC with extensive comments, it's meant to b

Releases(v0.1.0)
Owner
Sprite
C++, C, Rust. | Desktop & Windows kernel driver developer, reverse engineer.
Sprite
A simpler and 5x faster alternative to HashMap in Rust, which doesn't use hashing and doesn't use heap

At least 5x faster alternative of HashMap, for very small maps. It is also faster than FxHashMap, hashbrown, ArrayMap, and nohash-hasher. The smaller

Yegor Bugayenko 12 Apr 19, 2023
A typemap for a set of known types optionally without heap allocation, and supporting iterating by traits

fixed_typemap docs.rs GitHub Sponsors Implements typemaps that support a lot of extra funcctionality using procedural macros. docs.rs has a lot more t

Austin Hicks 2 Dec 27, 2021
A heap allocated runtime for deeply recursive algorithms.

Reblessive A heap allocated runtime for deeply recursive algorithms. Turn your cursed recursive algorithm into a blessed heap allocated structure whic

Mees Delzenne 4 Feb 27, 2024
Rust-idiomatic, compliant, flexible and performant BIP21 crate

Rust implementation of BIP21 Rust-idiomatic, compliant, flexible and performant BIP21 crate. About Important: while lot of work went into polishing th

Martin Habovštiak 6 Dec 15, 2022
A typesafe, flexible, simple, and user-friendly unit system library for Rust that has good error messages.

uy A typesafe, flexible, simple, and user-friendly unit system library for Rust that has good error messages. Usage uy not only stores the unit of a v

Lachlan Sneff 19 Aug 8, 2023
A flexible, stateless implementation of the bisection method

Flexibility is achieved by giving the user of this crate control over the input and output types

Martijn Gribnau 2 Nov 8, 2022
🤩 Flexible interpreted programming language

Jel Flexible, memory-safe, easy-to-use, interpreted programming language. work in progress Example Hello World: print(Hello World!) # this is valid pr

0x707 4 Sep 18, 2022
A backend framework for building fast and flexible APIs rapidly.

Andromeda Andromeda is a backend framework for Rust, to simplify the development of the kinds of basic API services that we developers have to build s

Framesurge 7 Dec 28, 2022
A fast and flexible LRU map.

A fast and flexible LRU map This repository contains a fast and flexible LRU map. Blazingly fast. Up to twice as fast as the lru crate, and with less

Koute 67 Jan 1, 2023
Rust crate for obfuscating string literals.

Obfustring This crate provides a obfuscation macro for string literals. This makes it easy to protect them from common reverse engineering attacks lik

null 7 Mar 1, 2023