Bug 60703

Summary: CSS: Fast path for 'px' lengths should be case-insensitive.
Product: WebKit Reporter: Andreas Kling <kling>
Component: CSSAssignee: Andreas Kling <kling>
Status: RESOLVED FIXED    
Severity: Normal CC: ian
Priority: P2 Keywords: Performance
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Proposed patch darin: review+

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>