Closed Bug 1577389 Opened 5 years ago Closed 5 years ago

nsStyleMargin::GetMargin and nsStylePadding::GetPadding are a bit slow

Categories

(Core :: CSS Parsing and Computation, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED
mozilla70
Tracking Status
firefox70 --- fixed

People

(Reporter: heycam, Assigned: heycam)

Details

Attachments

(1 file)

We call these for most elements during reflow. Values of 0 for margin and padding are very common, and we can check for such values and return nsMargin(0, 0, 0, 0) without having to do all the FP math for converting the LengthPercentage to an in-range nscoord.

The upcoming patch makes time spent under StyleCSSPixelLength::ToAppUnits (which is where all the time under GetMargin and GetPadding is taken) drop from 62 ms to 4 ms on https://en.wikipedia.org/wiki/Barack_Obama page load on my machine.

Zero lengths are common, and we can avoid doing all the FP math.

Pushed by cmccormack@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/d4a2b6867f3e
Return early from StyleCSSPixelLength::ToAppUnits for zero lengths. r=emilio
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla70
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: