[Webkit-unassigned] [Bug 42965] CSS: Add fast-path for rgba() color parsing

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon Aug 16 16:30:04 PDT 2010


https://bugs.webkit.org/show_bug.cgi?id=42965


Darin Adler <darin at apple.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #63446|review?                     |review+
               Flag|                            |




--- Comment #15 from Darin Adler <darin at apple.com>  2010-08-16 16:30:03 PST ---
(From update of attachment 63446)
> +    int length = end - string;
> +    if (length < 2)
> +        return false;

So just plain "0" and "1" are not in the fast path?

> +    if ((length == 4 && string[0] == '0' && string[1] == '.' && isASCIIDigit(string[2])
> +        || (length == 3 && string[0] == '.' && isASCIIDigit(string[1])))) {

Might be nice to use a helper function just to make this if statement easier to read.

> +        switch (string[length - 2]) {
> +        case '0': value = 0; break;
> +        case '1': value = 25; break;
> +        case '2': value = 51; break;
> +        case '3': value = 76; break;
> +        case '4': value = 102; break;
> +        case '5': value = 127; break;
> +        case '6': value = 153; break;
> +        case '7': value = 179; break;
> +        case '8': value = 204; break;
> +        case '9': value = 230; break;
> +        }

Seems like a small array would work better here than a switch.

> +    Vector<char, 256> bytes(length + 1);

The number 256 seems a little high here.

r=me

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list