Bug 12283 - SVG wastes time in stringToLengthType, should use CSS parser (or atoms) instead
Summary: SVG wastes time in stringToLengthType, should use CSS parser (or atoms) instead
Status: RESOLVED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: SVG (show other bugs)
Version: 420+
Hardware: Mac OS X 10.4
: P4 Normal
Assignee: Rob Buis
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-01-15 07:42 PST by Eric Seidel (no email)
Modified: 2012-05-30 08:00 PDT (History)
0 users

See Also:


Attachments
First attempt (4.44 KB, patch)
2007-01-27 12:51 PST, Rob Buis
darin: review-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Seidel (no email) 2007-01-15 07:42:41 PST
SVG wastes time in stringToLengthType, should use CSS parser (or atoms) instead

SVG is wasting time in stringToLengthType (in DOM string creation and destruction).  The HTML side of things just uses the CSS parser to extract length type during length parsing.  SVGLength should either find a cheaper method for parsing, or use the CSS parser code.

I discovered this by using the "heavy" view in shark, noting the malloc was heavy, and then seeing that stringToLengthType was under the String::String() malloc caller.
Comment 1 Rob Buis 2007-01-27 12:51:16 PST
Created attachment 12716 [details]
First attempt

Here is one possible solution. I am not sure whether it is the best but it should be more efficient.
Cheers,

Rob.
Comment 2 Darin Adler 2007-01-28 18:15:51 PST
Comment on attachment 12716 [details]
First attempt

I think this code has a buffer overrun. It looks at ptr[1] without checking if end is == ptr + 1.

Also, I think that String::endsWith should have a fast case for a char* parameter that avoids creating a String. There's really no need to rewrite this code to avoid allocating those String objects -- that should be fixed in the String class.

This patch also changes behavior -- it adds a new "isWhitespace" check, and it checks after the current ptr value rather than looking at the end of the string -- the old code would allow arbitrary text between the number and the unit type. The new code allows arbitrary text after the unit type. I'm not sure either of these is correcet.

We need a test case showing the change in behavior and if possible, systematically testing as many of the edge cases as possible.
Comment 3 Alexey Proskuryakov 2010-06-11 16:23:58 PDT
This code hasn't changed since this bug was filed, so it must still be an issue.
Comment 4 Rob Buis 2011-05-15 13:50:39 PDT
I think the patch for r68307 fixed this one as well.
Cheers,

Rob.
Comment 5 Rob Buis 2012-05-30 08:00:46 PDT
The code changed, it should be pretty efficient now. Closing.