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.
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 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.
This code hasn't changed since this bug was filed, so it must still be an issue.
I think the patch for r68307 fixed this one as well. Cheers, Rob.
The code changed, it should be pretty efficient now. Closing.