Closed Bug 347705 Opened 19 years ago Closed 19 years ago

[FIX]Would it be faster to not call LookupKeyword in TranslateDimension?

Categories

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

x86
Linux
defect

Tracking

()

RESOLVED FIXED
mozilla1.9alpha1

People

(Reporter: bzbarsky, Assigned: bzbarsky)

Details

(Keywords: perf)

Attachments

(1 file, 1 obsolete file)

Calls to LookupKeyword via TranslateDimension are about 1% of total time on the testcase at <http://www.speich.net/computer/3d.php>. For comparison, all of reflow is about 4-5%. I wonder whether we could avoid calling LookupKeyword here altogether...
This is really hard to read and doesn't seem like a good approach, but it _is_ faster. Frankly, I'm almost tempted by a linear search down the unit list (with the most common units up front). There are few enough units that this might be faster than the nsCSSKeywords lookup (esp. because the latter ends up doing string copies).
And of course putting 'px', 'em', 'ex', and 'pt' first would cover almost all of the use cases...
Keywords: perf
Attached patch Using a loopSplinter Review
Assignee: dbaron → bzbarsky
Attachment #232499 - Attachment is obsolete: true
Status: NEW → ASSIGNED
Attachment #232657 - Flags: superreview?(dbaron)
Attachment #232657 - Flags: review?(dbaron)
Priority: -- → P3
Target Milestone: --- → mozilla1.9alpha
Summary: Would it be faster to not call LookupKeyword in TranslateDimension? → [FIX]Would it be faster to not call LookupKeyword in TranslateDimension?
Comment on attachment 232657 [details] [diff] [review] Using a loop r+sr=dbaron
Attachment #232657 - Flags: superreview?(dbaron)
Attachment #232657 - Flags: superreview+
Attachment #232657 - Flags: review?(dbaron)
Attachment #232657 - Flags: review+
Checked in.
Status: ASSIGNED → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
fwiw, added build noise: In member function ‘PRBool CSSParserImpl::TranslateDimension(nsresult&, nsCSSValue&, PRInt32, float, const nsString&)’: http://lxr.mozilla.org/mozilla/source/layout/style/nsCSSParser.cpp#3611 warning: comparison between signed and unsigned integer expressions 3610 PRInt32 i; 3611 for (i = 0; i < NS_ARRAY_LENGTH(UnitData); ++i) { s/PRInt32/PRUint32/ helps
Fixed that.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: