Skip to content

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
@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.

2 participants