Skip to content

Commit

Permalink
refactor: deduplicated heap-optimized vectors (#636)
Browse files Browse the repository at this point in the history
* feat: added `heapopt` crate with `Vec`
* refactor: use `heapopt::Vec` wherever possible
  • Loading branch information
pamburus authored Dec 28, 2024
1 parent a0caafd commit df88e75
Show file tree
Hide file tree
Showing 8 changed files with 504 additions and 132 deletions.
27 changes: 27 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace]
members = [".", "crate/encstr"]
members = [".", "crate/encstr", "crate/heapopt"]

[workspace.package]
repository = "https://github.com/pamburus/hl"
Expand Down Expand Up @@ -53,6 +53,7 @@ enumset-ext = { path = "./crate/enumset-ext" }
env_logger = "0"
flate2 = "1"
heapless = "0"
heapopt = { path = "./crate/heapopt" }
hex = "0"
htp = { git = "https://github.com/pamburus/htp.git" }
humantime = "2"
Expand Down
14 changes: 14 additions & 0 deletions crate/heapopt/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[package]
name = "heapopt"
version = "0.1.0"
repository.workspace = true
authors.workspace = true
edition.workspace = true
license.workspace = true

[dependencies]
derive-where = "1"
heapless = "0"

[dev-dependencies]
more-asserts = "0"
14 changes: 14 additions & 0 deletions crate/heapopt/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//! Data structures that allow optimization for rare heap usage.
//! Optimization can be achieved by storing part of the data in a fixed size heapless part.
//! If that capacity is not enough, the rest is stored in a heap allocated part.
pub mod vec;

/// Vec is a re-export of the [`vec::Vec`]`.
pub type Vec<T, const N: usize> = vec::Vec<T, N>;

/// VecIter is a re-export of the [`vec::Iter`]`.
pub type VecIter<'a, T> = vec::Iter<'a, T>;

/// VecIterMut is a re-export of the [`vec::IterMut`]`.
pub type VecIterMut<'a, T> = vec::IterMut<'a, T>;
Loading

0 comments on commit df88e75

Please sign in to comment.