Performance improvements and upgrade to Zig 0.16#4
Open
lvignoli wants to merge 26 commits into
Open
Conversation
This saves allocation of a new buffer just for the current number encoding.
We know we'll have less than 128 characters in the alphabet. It is an overestimation, as some ASCII characters are not printable and will probably never been used in an alphabet. Also fixes the previous wrong 256 value here and there.
Thanks a lot Karl Seguin.
BREAKING CHANGE: Sqid struct is now unmanaged. Sqid.init takes no allocator. Calls to encode and decode take an allocator.
init suggests that it must be deinit afterwards. Since Sqid is now an unmanaged struct, there is no deinit. A constructor is still required for validation of the options arguments, I call it new.
Prefer a plain list of words, and let the user handle optimizations.
There were breaking changes on the API, and upgrade to Zig 0.16.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This MR contains several performance improvements, mostly by reducing the generous use of allocations found in the former version.

Using crap, I observe a 9-fold improvement in runtime on my machine for the simple and dummy
bench.zigbenchmark that encodes a thousands UUID in a row with default settings.I took the breaking change opportunity to upgrade to Zig 0.16, so I am tagging a new version.