Closed Bug 1471584 Opened 6 years ago Closed 6 years ago

Avoid using a virtual call within gfxHarfBuzzShaper::HBGetGlyphHAdvance

Categories

(Core :: Graphics: Text, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED
mozilla63
Tracking Status
firefox63 --- fixed

People

(Reporter: jfkthame, Assigned: jfkthame)

Details

Attachments

(1 file)

This is a very hot function when doing text layout -- it's called for every glyph the shaper processes. Currently, it calls the gfxFont's ProvidesGlyphWidths() method, which is a virtual function, to determine which implementation to use. We should avoid that.

The result of ProvidesGlyphWidths() is already cached in the shaper object, so by just checking that flag instead we can avoid the virtual call here in the inner loop of text shaping.

(The perf benefit will be lost in the noise for normal cases, but with an extreme testcase that involves shaping multiple megabytes of text, I'm measuring a definite improvement in total reflow time, from ~6200ms to ~5950ms.)
Assignee: nobody → jfkthame
Status: NEW → ASSIGNED
Attachment #8988151 - Flags: review?(lsalzman) → review+
Pushed by jkew@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/1b9dcb1b80dd
Micro-optimize text shaping by avoiding an unnecessary virtual method call. r=lsalzman
https://hg.mozilla.org/mozilla-central/rev/1b9dcb1b80dd
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla63
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: