Last Comment Bug 735439 - reorder fields in gfxFontStyle for more efficient packing
: reorder fields in gfxFontStyle for more efficient packing
Status: RESOLVED FIXED
:
Product: Core
Classification: Components
Component: Graphics (show other bugs)
: Trunk
: All All
: -- normal (vote)
: mozilla14
Assigned To: Jonathan Kew (:jfkthame)
:
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-03-13 14:09 PDT by Jonathan Kew (:jfkthame)
Modified: 2012-03-16 06:05 PDT (History)
2 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
patch, optimize order of fields in gfxFontStyle to save space (6.51 KB, patch)
2012-03-13 14:09 PDT, Jonathan Kew (:jfkthame)
jd.bugzilla: review+
Details | Diff | Splinter Review

Description Jonathan Kew (:jfkthame) 2012-03-13 14:09:42 PDT
Created attachment 605533 [details] [diff] [review]
patch, optimize order of fields in gfxFontStyle to save space

The attached patch rearranges fields so that sizeof(gfxFontStyle) drops from 48 to 40 bytes on a 64-bit OS X build. Given that we can easily have thousands of gfxFontStyle records alive at any one time, this seems like a worthwhile saving.
Comment 1 John Daggett (:jtd) 2012-03-14 18:58:13 PDT
Comment on attachment 605533 [details] [diff] [review]
patch, optimize order of fields in gfxFontStyle to save space


r+ with fix noted below.

> +    // The style of font (normal, italic, oblique)
> +    PRUint8 style : 6;

This should be 'style : 2', there's no real reason to be doing the
padding ourselves, this leads to bytes inadvertently being added when
new fields are added, as seems to be the case in the original 'style :
7' definition.
Comment 3 Marco Bonardo [::mak] (Away 6-20 Aug) 2012-03-16 05:55:01 PDT
https://hg.mozilla.org/mozilla-central/rev/5f438ea9ded4
Comment 4 :Ms2ger (⌚ UTC+1/+2) 2012-03-16 06:05:33 PDT
Comment on attachment 605533 [details] [diff] [review]
patch, optimize order of fields in gfxFontStyle to save space

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

::: gfx/thebes/gfxFont.h
@@ +165,5 @@
> +    // Say that this font is used for print or print preview.
> +    bool printerFont : 1;
> +
> +    // The style of font (normal, italic, oblique)
> +    PRUint8 style : 6;

Note that MSVC apparently only packs members of the same type.

Note You need to log in before you can comment on or make changes to this bug.