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

chore: early exit when encoding invalid numbers #14

Merged

Conversation

EvanHahn
Copy link
Contributor

Before this change, we checked the validity of every number during encoding. Now, we stop if we find an invalid one.

In my testing, this was about twice as fast for invalid inputs. It had no performance impact for valid inputs, but should theoretically avoid an unnecessary array allocation.

Before this change, we checked the validity of every number during
encoding. Now, we stop if we find an invalid one.

In my testing, this was about twice as fast for invalid inputs. It had
no performance impact for valid inputs, but should theoretically avoid
an unnecessary array allocation.
@4kimov 4kimov merged commit 877b8e6 into sqids:main Nov 26, 2023
5 checks passed
@4kimov
Copy link
Member

4kimov commented Nov 26, 2023

Very nice, thank you 💪

@EvanHahn EvanHahn deleted the early-exit-when-encoding-invalid-numbers branch November 26, 2023 15:45
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

2 participants