Closed Bug 399349 Opened 17 years ago Closed 15 years ago

nsCSSScanner: Optimize parseNum to handle integer numbers directly

Categories

(Core :: CSS Parsing and Computation, defect)

defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 498559

People

(Reporter: alfredkayser, Assigned: alfredkayser)

References

Details

(Keywords: perf)

Attachments

(1 file, 2 obsolete files)

This patch optimizes number parsing for numbers without a '.' and up to 9 digits directly as an intValue, skipping the 'ident' gathering for such numbers.
All other numbers (more than 9 digits or a '.' present) are handled in the usual way: collect into the ident string, and then do ToFloat.

This way we prevent all kinds of overflow issues, but optimize the most common type of numbers in CSS sheets (e.g. 1px, 2px, 0, etc).
Attachment #284353 - Flags: review?(dbaron)
Status: NEW → ASSIGNED
Assignee: nobody → alfredkayser
Status: ASSIGNED → NEW
Status: NEW → ASSIGNED
OS: Windows XP → All
Hardware: PC → All
1. normal integers are always directly parsed, no conversion.
2. normal floats (<9 digits before .) only ToFloat for fraction part,
3. huge floats (>9 digits before .) AppendInt and ToFloat for conversion.
Attachment #284353 - Attachment is obsolete: true
Attachment #284353 - Flags: review?(dbaron)
Keywords: perf
Version: unspecified → Trunk
Attachment #284444 - Flags: superreview?(bzbarsky)
Attachment #284444 - Flags: review?(dbaron)
I won't get to this until May at best.
Comment on attachment 284444 [details] [diff] [review]
V2: Only use AppendInt when we have more than 9 digits before the dot

No tests or information about what was tested ==> review-
Attachment #284444 - Flags: review?(dbaron) → review-
Blocks: 42953
Attachment #284444 - Flags: superreview?(bzbarsky)
I have created a special testfile with 24 testcases for number parsing.
Together with the testcases in test_parse_rule.html this should cover number parsing of a wide range of scenarios.

Note floating point numbers are stored as 'float' and are thus very limited in precision. Also the CSS code itself massages numbers.

Anyway these testcases caught a number of issues with I have solved with this patch.
Attachment #284444 - Attachment is obsolete: true
Attachment #305359 - Flags: review?(dbaron)
Nits:
s/zero's/zeroes
s/numers/numbers
Did you test that actually improved performance?  On what testcases?
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Resolution: --- → DUPLICATE
Comment on attachment 305359 [details] [diff] [review]
V3: With a bunch of testcases for number parsing

Clearing review request on obsolete patch; looks like Boris already landed the test.
Attachment #305359 - Flags: review?(dbaron)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: