Open
Bug 573453
Opened 15 years ago
Updated 3 years ago
Consider a caching mechanism to avoid repeatedly looking up font/viewport information
Categories
(Core :: SVG, defect)
Core
SVG
Tracking
()
NEW
People
(Reporter: jwatt, Unassigned)
Details
(Keywords: perf)
Currently we can end up repeatedly looking up the same font or viewport dimension information for SVGLength objects. If we could pass a "context" object to SVGLength methods instead of passing in its element etc., then that context object could look up font size and viewport dimensions lazily, and cache it. The object could be created on the stack, then passed to the SVGLength objects for each relevant attribute of an element, which in the case of <length-list> attributes may be a lot of SVGLength objects.
Note that the viewport element for an element may itself have percentage values making it depend on *its* viewport, and so on.
![]() |
Reporter | |
Comment 1•15 years ago
|
||
Here's some very rough draft code I stripped out of the patch for bug 515116.
/**
* Performance enhancing class to lookup length context data on demand and
* cache it for reuse with other lengths.
* Create one of these on the stack and pass it into each GetValueInUserUnits
* call when you need to get the user unit length of multiple SVGLength
* objects belonging to the same element.
*/
class Context {
Context(nsSVGElement *aElement) : mElement(aElement) {}
float GetViewportWidth() {
if (!aFoundViewport) LookupViewport();
return mViewportWidth;
}
float GetViewportHeight() {
if (!aFoundViewport) LookupViewport();
return mViewportHeight;
}
private:
Context();
nsSVGElement *mElement;
float mViewportWidth;
float mViewportHeight;
PRBool aFoundViewport;
};
Updated•3 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•