diff --git a/lib/CHANGELOG.md b/lib/CHANGELOG.md index 679e828..8187d74 100644 --- a/lib/CHANGELOG.md +++ b/lib/CHANGELOG.md @@ -8,6 +8,7 @@ ### Patch +- Reserve the full length when building an encoding from a specification - Clarify wrapping behavior on empty output in documentation - Fix `redundant_explicit_links` rustdoc lint - Rename lints in `Cargo.toml` to use underscores diff --git a/lib/src/lib.rs b/lib/src/lib.rs index f90a44c..e1888b7 100644 --- a/lib/src/lib.rs +++ b/lib/src/lib.rs @@ -1983,7 +1983,9 @@ impl Specification { check!(SpecificationError(Undefined(to[i])), v != INVALID); set(&mut values, from[i], v)?; } - let mut encoding = Vec::new(); + // The implementation is 256 symbols, 256 values, padding, bit-order and bit-width, and + // optionally the wrap width and separator (or a zero width for ignore). + let mut encoding = Vec::with_capacity(515 + wrap.map_or(0, |(_, end)| end.len())); for _ in 0 .. 256 / symbols.len() { encoding.extend_from_slice(symbols); }