Closed Bug 1487989 Opened 2 years ago Closed 2 years ago

webdriver: Deref the matched expression instead of each variant

Categories

(Testing :: geckodriver, enhancement)

enhancement
Not set

Tracking

(firefox64 fixed)

RESOLVED FIXED
mozilla64
Tracking Status
firefox64 --- fixed

People

(Reporter: ato, Assigned: ato)

References

(Blocks 1 open bug)

Details

Attachments

(1 file, 1 obsolete file)

When matching we can dereference the expression we match on instead
of prefixing each variant with &:

> match self {
>     &NewSessionParameters::Spec(ref x) => x.match_browser(browser_capabilities),
>     &NewSessionParameters::Legacy(ref x) => x.match_browser(browser_capabilities),
> }

Instead:

> match *self {
>     NewSessionParameters::Spec(ref x) => x.match_browser(browser_capabilities),
>     NewSessionParameters::Legacy(ref x) => x.match_browser(browser_capabilities),
> }
Assignee: nobody → ato
Status: NEW → ASSIGNED
Instead of accessing each variant using a reference, we should
dereference the matched expression when possible.
Attachment #9005822 - Flags: review?(hskupin)
Please see bug 1465381 for how it should be done. Also I think if you make your commit message that generic, please also check the remaining code of webdriver for updates. I barely believe this is the only place which needs an update.
Blocks: 1465381
Attachment #9005822 - Flags: review?(hskupin)
Instead of accessing each variant using a reference, we should
dereference the matched expression when possible.
Attachment #9005991 - Flags: review?(hskupin)
Attachment #9005822 - Attachment is obsolete: true
(In reply to Henrik Skupin (:whimboo) from comment #2)

> Also I think if you make your commit message that generic, please
> also check the remaining code of webdriver for updates. I barely
> believe this is the only place which needs an update.

These were the only two cases clippy complained about, and I didn’t
find any other when inspecting the code by hand.  But you’re welcome
to have a look:
https://searchfox.org/mozilla-central/search?q=%5Cs%7B4%7Dmatch%5Cs&case=false&regexp=true&path=testing%2Fwebdriver%2F**%2F*.rs
Comment on attachment 9005991 [details] [diff] [review]
webdriver: deref matched expressions

Review of attachment 9005991 [details] [diff] [review]:
-----------------------------------------------------------------

No, I think you are right and this looks fine. Thanks.
Attachment #9005991 - Flags: review?(hskupin) → review+
Pushed by ato@sny.no:
https://hg.mozilla.org/integration/mozilla-inbound/rev/5a41ca05867b
webdriver: deref matched expressions; r=whimboo
https://hg.mozilla.org/mozilla-central/rev/5a41ca05867b
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla64
Target Milestone: mozilla64 → mozilla63
Target Milestone: mozilla63 → mozilla64
You need to log in before you can comment on or make changes to this bug.