Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Precise decode output slice length checking #269

Merged
merged 6 commits into from Mar 2, 2024

Conversation

marshallpierce
Copy link
Owner

No description provided.

~6% speedup on decode_slice/3
- Rearrange main decoding loops to handle chunks of 32 bytes at a time, then 4 bytes at a time, meaning that `decode_suffix` need only handle 0-4 bytes, simplifying its code. Moderate speed gains of around 5-10%.
- Improve error precision. `InvalidLength` now has a `usize` length indicating how many valid symbols were found, but that the count of those symbols was invalid. Before, it just did `input % 4 == `, which was harder to reason about, as there might be padding etc. DecoderReader now also precisely reports the suitable InvalidByte if an earlier block of decoding found padding that was valid in that context, but more padding was found later, rendering that earlier padding invalid.
- Tidy up decode tests. There were some duplicated scenarios, and certain aspects are now tested in more detail.
Implementations must now precisely, not conservatively, return an error when the output length is too small.
The logic isn't important, but it helps make actual coverage gaps more visible.
@marshallpierce
Copy link
Owner Author

Fixes #210

@marshallpierce marshallpierce merged commit 5d70ba7 into master Mar 2, 2024
5 checks passed
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.

None yet

1 participant