Closed Bug 1163488 Opened 9 years ago Closed 9 years ago

replace pref lang lookup arrays with preprocessor generated arrays

Categories

(Core :: Graphics: Text, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla42
Tracking Status
firefox40 --- affected
firefox42 --- fixed

People

(Reporter: jtd, Assigned: jtd)

References

Details

(Whiteboard: gfx-noted)

Attachments

(1 file)

There's code in gfxPlatform.cpp for mapping language strings used in all.js to a pref lang enum. There are various arrays that must be maintained in an associated order:

http://mxr.mozilla.org/mozilla-central/source/gfx/thebes/gfxPlatform.cpp#353
http://mxr.mozilla.org/mozilla-central/source/gfx/thebes/gfxPlatform.h#75

Karl thinks this is too brittle and that we should use lookups that rely on case statements and simply let the compiler optimize the lookup code.

https://bugzilla.mozilla.org/show_bug.cgi?id=1056479#c79
Summary: replace pref lang lookup arrays with case statement → replace pref lang lookup arrays with switch statements
Another option would be to use the C preprocessor (like nsCSSPropList.h, nsCSSPseudoClassList.h, nsCSSFontDescList.h, etc.).
Blocks: 1164735
> Karl thinks this is too brittle and that we should use lookups that rely on
> case statements and simply let the compiler optimize the lookup code.

Large case statements usually cause lots of mispredicted branches. A lookup table is usually better.

> Another option would be to use the C preprocessor (like nsCSSPropList.h,
> nsCSSPseudoClassList.h, nsCSSFontDescList.h, etc.).

+1 to this. It would allow you to keep the lookup table, while also guaranteeing the different parts of the code follow the same ordering.
Blocks: 1056479
Summary: replace pref lang lookup arrays with switch statements → replace pref lang lookup arrays with preprocessor generated arrays
Whiteboard: gfx-noted
Consolidate the data arrays maintained for use with pref font handling into a shared list. Use preprocessor to populate arrays and maintain ordering between enum and lang atom/strings.

We can probably eliminate the string from the list but that requires a certain amount of refactoring within the pref font code, so that's a bigger job.
Attachment #8631917 - Flags: review?(m_kato)
Attachment #8631917 - Flags: review?(m_kato) → review+
https://hg.mozilla.org/mozilla-central/rev/ca220c8e9883
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla42
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: