umbra_slice

Crates.ioumbra_slice
lib.rsumbra_slice
version0.1.0
sourcesrc
created_at2024-11-07 23:12:51.727622
updated_at2024-11-07 23:12:51.727622
descriptionAn owned slice type with German string optimizations
homepage
repositoryhttps://github.com/the-mikedavis/umbra_slice
max_upload_size
id1440451
size55,707
Michael Davis (the-mikedavis)

documentation

README

umbra_slice

umbra_slice provides a generic slice type that can replace Box<[T]> and Box<str>. UmbraSlice<T> is optimized to store small slices inline in a layout based on "German strings".

umbra_slice was extracted from spellbook. See the post "German string" optimizations in Spellbook for more details.

Quick facts

  • Takes 16 bytes on the stack.
  • Stores up to 14 bytes inline.
  • Optimization for Eq to disqualify strings with different lengths and prefixes quickly.
  • Can be used to store 16 or 32 bit integers as well as u8s.

(Assuming a 64-bit machine.)

Use-cases

UmbraSlice<T> and UmbraString are designed for a specific use-case and should not be thought of as generic replacements for Vec<T>/Box<[T]> and String/Box<str>, respectively. If you need a generic replacement, consider one of many great existing crates like smallvec. UmbraSlice<T> differs from most existing crates because it focuses on emulating non-resizable, immutable slices rather than resizable and mutable Vec<T>s (which typically take 24 bytes on the stack).

Umbra slices are immutable and have a shorter maximum length than Vecs or boxed slices. Umbra slices are meant to be used when you have very many (thousands+) slices or strings which are typically smaller than 14 bytes.

License

Licensed under either of:

at your option.

Commit count: 8

cargo fmt