-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
8504 duplicate match exp #8542
8504 duplicate match exp #8542
Conversation
return true; | ||
} | ||
return false; | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that this is O(n^2)
, so might get really slow when the filter has a lot of values (although not sure how likely we are to hit this in practice). An alternative would be to sort the values and then filter linearly, since it doesn't matter what order they are in the match
expression:
const uniqueValues = values.sort().filter((v, i) => values[i - 1] !== v);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: you can write this shorter without curly brackets, return
and on one line.
return true; | ||
} | ||
return false; | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: you can write this shorter without curly brackets, return
and on one line.
Closes #8504
The utility to convert legacy filters to expressions currently outputs a
match
expression as an optimization for certain legacyin, !in
operators. This PR removes duplicate values from the result to ensure that the expression is valid.