-
Notifications
You must be signed in to change notification settings - Fork 228
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
Bug 1919541 - Implement variant handling in the search engine selector. #6536
Conversation
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.
Thank you. This looks good. I had a suggestion for renaming the parameters of the merge
function and the other parts all look good to me.
components/search/src/filter.rs
Outdated
fn merge(self, other: Self) -> Self { | ||
Self { | ||
base: other.base.or(self.base), | ||
method: other.method.or(self.method), | ||
params: other.params.or(self.params), | ||
search_term_param_name: other.search_term_param_name.or(self.search_term_param_name), | ||
} | ||
} | ||
} |
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.
I'm a bit confused with the parameter naming or lack of naming. It's confusing to figure out which Url is overriding the other Url because there's self
and other: Self
. I know the first one is just referring to the type self
which is JSONEngineUrl. It wasn't obvious at first and I had mixed them up.
I'm wondering if we're able to change function definition to any of these?
fn merge(baseUrl: Self, variantUrl: Self) -> Self
fn merge(baseUrl: Self, overrideUrl: Self) -> Self
I was reading about Associated Functions and if we change the function definition with a explicit parameter name, then this changes to an associated function and we might need to call it in a different way:
JSONEngineUrl::merge(url1, url2)
rather than url1.merge(url2)
My other thought is, if you'll like to keep it as an instance method, maybe rename other
to overrideUrl
or variantUrl
?
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.
I thought about it a bit, and decided to go with associated functions, since they seemed better for what was actually going on - merging two objects & returning a new one (rather than modifying one of them in-place).
I've also switched to using original
and preferred
as I think that is hopefully clear than base/variant - the merge functions don't care about what is being merged.
Question: I know this PR isn't about sub-variants, but I was just curious and wanted to verify. If there's a list of sub-variants but none of them match, we match the last top-level variant that was matched. Is that right? |
If a top-level variant matches, then it is applied, regardless of if there's a matching sub-variant or not. If there is a matching sub-variant, then that will be applied on top i.e. take the base, merge the variant, (maybe) merge the sub-variant. |
f6fb672
to
bf2d39a
Compare
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.
Oops, I had these small pending style suggestions, and never submitted them!
bf2d39a
to
45f2123
Compare
Thank you! |
This implements handling for search engine variants within the selector. It does not handle sub-variants at this time, that will be handled in a follow-up.
No changelog/API entries as this isn't currently used anywhere.
Pull Request checklist
[ci full]
to the PR title.Branch builds: add
[firefox-android: branch-name]
to the PR title.