Skip to content

Miscellaneous cleanup and improvements - #1

Open
tox-wtf wants to merge 7 commits into
xoogware:masterfrom
tox-wtf:lib-cleanup
Open

Miscellaneous cleanup and improvements#1
tox-wtf wants to merge 7 commits into
xoogware:masterfrom
tox-wtf:lib-cleanup

Conversation

@tox-wtf

@tox-wtf tox-wtf commented May 6, 2026

Copy link
Copy Markdown

This patchset contains some small changes I made while poking around the library. See commit descriptions for more information.

Warning

I'm pretty sure I didn't break anything, but please test this. There's no test suite, and I don't know where to get my hands on test data.

tox-wtf added 7 commits May 6, 2026 05:10
`WorldFlags` wraps `u8`. It's more efficient to pass arguments this
small by value than by reference.
Convenient though it may be, `zstd::decode_all()` repeatedly allocates
memory for a new `result` vector[^1]. We can dodge these unnecessary
allocations by calling `zstd::stream::copy_decode()` directly and
allocating `uncompressed_chunks_size` bytes to an `uncompressed` vector
once.

I renamed the vector associated with `uncompressed_chunks_size` from
`decoded` to `uncompressed` for consistency.

[^1]: See code for `zstd::decode_all()`:

    ```rust
    pub fn decode_all<R: io::Read>(source: R) -> io::Result<Vec<u8>> {
        let mut result = Vec::new();
        copy_decode(source, &mut result)?;
        Ok(result)
    }
    ```
More informative logs and address a lint.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant