-
Notifications
You must be signed in to change notification settings - Fork 448
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
Introduce result objects and improve static analysis #267
Merged
Conversation
This file contains 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
Signed-off-by: Luís Cobucci <[email protected]>
Signed-off-by: Luís Cobucci <[email protected]>
Signed-off-by: Luís Cobucci <[email protected]>
Allowing us to remove the `assert()` calls from the code. Signed-off-by: Luís Cobucci <[email protected]>
This makes things easier to be updated. Signed-off-by: Luís Cobucci <[email protected]>
Signed-off-by: Luís Cobucci <[email protected]>
Using arrays for the dispatching result hinders type safety and forces us to dynamically verify what has happened. This introduces result objects with read-only public variables that are backwards compatible with the array shapes we were using, providing more flexibility and a type-based way to know if we have or not a match. It's really important to mention that we aren't calling the constructor with promoted read-only variables because of the average overhead of 60% on dispatching operations. Introducing objects with public properties also has an impact but it's significantly smaller (average overhead of 12%). I do believe that having an object there helps - as previously requested by several people. Signed-off-by: Luís Cobucci <[email protected]>
Verifying the shape to match our expectations would incur in unnecessary performance impact. This ignores the errors, accepting the situation. Signed-off-by: Luís Cobucci <[email protected]>
Signed-off-by: Luís Cobucci <[email protected]>
This makes things much less error-prone. Signed-off-by: Luís Cobucci <[email protected]>
Signed-off-by: Luís Cobucci <[email protected]>
This was referenced Jan 8, 2024
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 reviews the implementation to make things as type-safe as possible, whilst centralising the definition of array shapes.
We also introduce result objects (similar to #239) minimising the performance impact as much as possible, allowing users to handle the dispatching calls with different types.