Skip to content

Rust crate that implements compact storage of immutable strings

Notifications You must be signed in to change notification settings

ericseppanen/packed_str

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Packed Immutable Strings

PackedStr is a replacement for Vec<String> when the strings are all immutable.

The benefit of using PackedStr is that all of the string data is stored in a single heap allocation. This may save space compared to Vec<String>, where each String has its own heap allocation, and associated costs (excess String capacity, allocator metadata, heap fragmentation).

In addition, each String stores its own size and capacity, which are not necessary due to the PackedStr design.

PackedStr is implemented as one large buffer containing all the string data, and a list of indexes into the buffer. Each string slice can be reconstructed from its index, and the index of the next string (or the end of the buffer, for the last string).

About

Rust crate that implements compact storage of immutable strings

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages