Closed Bug 1360620 Opened 7 years ago Closed 7 years ago

Reduce size of gfxTextRun by optimizing glyphrun storage

Categories

(Core :: Graphics: Text, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla55
Tracking Status
firefox55 --- fixed

People

(Reporter: jfkthame, Assigned: jfkthame)

References

Details

Attachments

(1 file)

See https://dxr.mozilla.org/mozilla-central/rev/2cca333f546f38860f84940d4c72d7470a3410f4/gfx/thebes/gfxTextRun.h#760-762.

I propose to reduce the size of gfxTextRun by replacing the AutoTArray<GlyphRun,1> (32 bytes in a 64-bit build) with a union that holds either a single GlyphRun *or* an nsTArray<GlyphRun>, with a flag elsewhere in gfxTextRun to record which is currently present (we have a spare padding byte available for that). There will be a bit of overhead in AddGlyphRun when transitioning from a single glyphrun (stored inline) to two glyphruns (in an array), but that will be essentially equivalent to the work AutoTArray does when its autobuffer oveflows.

This should reduce the size of gfxTextRun by 16 bytes, yet have the same allocation behavior as at present: when there's a single GlyphRun, it is stored directly in the textrun with no separate heap allocation, and when there are multiple glyph runs, we have to allocate heap storage for the array (just as the autoarray does when its one-element buffer overflows).
Assignee: nobody → jfkthame
Status: NEW → ASSIGNED
Attachment #8862944 - Flags: review?(jmuizelaar)
Attachment #8862944 - Flags: review?(jmuizelaar) → review+
https://hg.mozilla.org/integration/mozilla-inbound/rev/dca52e4ed76197ec3e3629e659020c3d5c8d81bb
Bug 1360620 - Optimize GlyphRun storage strategy in gfxTextRun, to reduce the overall size of the gfxTextRun object. r=jrmuizel
Pushed by jkew@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/dca52e4ed761
Optimize GlyphRun storage strategy in gfxTextRun, to reduce the overall size of the gfxTextRun object. r=jrmuizel
https://hg.mozilla.org/mozilla-central/rev/dca52e4ed761
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla55
Depends on: 1361648
Depends on: 1361395
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: