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

Introduce result objects and improve static analysis #267

Merged
merged 11 commits into from
Jan 8, 2024

Conversation

lcobucci
Copy link
Collaborator

@lcobucci lcobucci commented Jan 8, 2024

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.

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]>
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]>
This makes things much less error-prone.

Signed-off-by: Luís Cobucci <[email protected]>
@lcobucci lcobucci added this to the 2.0.0 milestone Jan 8, 2024
@lcobucci lcobucci self-assigned this Jan 8, 2024
@lcobucci lcobucci merged commit 68a2232 into master Jan 8, 2024
32 of 33 checks passed
@lcobucci lcobucci deleted the several-static-analysis-improvements branch January 8, 2024 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant