Bug 60703 - CSS: Fast path for 'px' lengths should be case-insensitive.
Summary: CSS: Fast path for 'px' lengths should be case-insensitive.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Andreas Kling
URL:
Keywords: Performance
Depends on:
Blocks:
 
Reported: 2011-05-12 09:14 PDT by Andreas Kling
Modified: 2011-05-16 05:42 PDT (History)
1 user (show)

See Also:


Attachments
Proposed patch (1.41 KB, patch)
2011-05-12 09:18 PDT, Andreas Kling
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Kling 2011-05-12 09:14:14 PDT
The fast-path for 'px' lengths added on bug 57964 only handles 'px' when in lowercase.
1px, 1PX, 1Px, etc are all valid CSS lengths, and we can easily support them in the fast-path.
Comment 1 Andreas Kling 2011-05-12 09:18:33 PDT
Created attachment 93293 [details]
Proposed patch
Comment 2 Darin Adler 2011-05-12 09:59:26 PDT
Comment on attachment 93293 [details]
Proposed patch

View in context: https://bugs.webkit.org/attachment.cgi?id=93293&action=review

> Source/WebCore/css/CSSParser.cpp:380
> +        && (characters[length - 2] == 'p' || characters[length - 2] == 'P')
> +        && (characters[length - 1] == 'x' || characters[length - 1] == 'X')) {

Another version would be:

    if (length > 2 && (characters[length - 2] | 0x20) == 'p' && (characters[length - 1] | 0x20) == 'x') {

This is more efficient on platforms where branches are expensive. We use this idiom elsewhere in CSSParser.cpp for rgb and we even have a function for it in KURL.cpp (isLetterMatchIgnoringCase) and LinkHash.cpp (matchLetter).
Comment 3 Andreas Kling 2011-05-16 05:42:54 PDT
Committed r86561: <http://trac.webkit.org/changeset/86561>