Files
craft-libs/crates/shared-vec/Cargo.toml
dotCooCoo fb66ff092e Add craft-shared-vec: an indexed list whose clones share their blocks
A document tree that keeps each container's children in an Arc<Vec<_>>
and edits them with Arc::make_mut copies the whole child list on every
edit while an undo snapshot still holds it. One edit on a layer of
100,000 objects copies 800 KB of handles.

SharedVec<T> keeps elements in leaves of up to 64 under a counted
B-tree with Arc blocks. get, set, get_mut, insert, remove, push and pop
take O(log n) and copy only the blocks on their path; append,
split_off, truncate, splice and retain rebuild the branches and keep
every leaf they do not change. bytes_not_in and bytes_not_in_with count
the blocks and element payloads one list holds and another does not,
for undo-history limits. With the serde feature a list reads and writes
as a plain sequence, the same bytes as a Vec.

The examples/bench.rs example times edits beside a kept snapshot and
iteration against Vec.
2026-11-22 09:49:02 -08:00

26 lines
744 B
TOML

[package]
name = "craft-shared-vec"
description = "An ordered, indexed list whose clones share storage: a counted B-tree of shared blocks, so an edit copies only the blocks on its path, with share-aware byte counts for undo history."
version.workspace = true
edition.workspace = true
license.workspace = true
rust-version.workspace = true
repository.workspace = true
[lints]
workspace = true
[features]
default = []
# Serialize and Deserialize as a plain sequence, the same as `Vec<T>`.
serde = ["dep:serde"]
[dependencies]
serde = { workspace = true, optional = true }
[dev-dependencies]
craft-shared-vec = { path = ".", features = ["serde"] }
proptest = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }