Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Enum matching improvement #80

Closed
Stranger6667 opened this issue May 22, 2020 · 0 comments · Fixed by #156
Closed

Enum matching improvement #80

Stranger6667 opened this issue May 22, 2020 · 0 comments · Fixed by #156

Comments

@Stranger6667
Copy link
Owner

Stranger6667 commented May 22, 2020

If all items in the enum are of the same type, then we can build a special validator for this type, in this case, we can speed up validation because for not matching types we won't need comparisons at all and for matching types, we'll have some improvement as well - we can store unwrapped values, unwrap the input value once during the matching step and then compare them in a loop, which should be faster.

{"enum": [1, 2, 3, 4, 5]}

If the input instance is "foo", then we don't need to iterate over all variants, we can return false immediately. The trick will work only for homogenous arrays

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant