Closed Bug 1607419 Opened 3 months ago Closed 3 months ago

option.expect(&format!(...)) runs formatting code unconditionally

Categories

(Core :: Graphics: WebRender, defect, P3)

defect

Tracking

()

RESOLVED FIXED
mozilla74
Tracking Status
firefox74 --- fixed

People

(Reporter: nical, Assigned: nical)

References

(Blocks 2 open bugs)

Details

Attachments

(1 file)

And it slows some code down. The biggest offender is in BrushSegment::update_clip_task. which I caught while profiling (so surprising that I initially assumed fmt::format was showing in the profile because of some symbolication error).

The majority of the remaining expect(&format! are in recording code so we don't need to worry about performance as much. Part of me itches to get rid of them as well just to prevent this knee-self-targeting pattern to look familiar.

Easy to miss that the slow formatting code is run unconditionally.
The remaining instances are in recording and startup code.

fwiw there's a clippy lint for this, and nical's fix is the suggested one: https://rust-lang.github.io/rust-clippy/master/index.html#expect_fun_call

Pushed by nsilva@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/031a2ee21fa6
Avoid option.expect(&format in hot code. r=jrmuizel
Status: NEW → RESOLVED
Closed: 3 months ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla74
You need to log in before you can comment on or make changes to this bug.