Closed Bug 473517 Opened 11 years ago Closed 11 years ago
Remove heap allocated ns
SVGLength in ns SVGUtils::Coord To Float
nsSVGUtils::CoordToFloat uses a short lived heap allocated nsSVGLength to do a calculation. This can be replaced with a stack allocated nsSVGLength2 to get the same effect.
Can you remove the include too? Also, any reason to not use: case eStyleUnit_Percent: nsSVGSVGElement* ctx = aContent->GetCtx(); return ctx ? aCoord.GetPercentValue() * ctx->GetLength(nsSVGUtils::XY) : 0;
I considered doing it, but the real length code also has a check for GetLength returning 0.0f and changes it to 1e-20. So I was trying to make this code simple by reuse existing stuff. While typing this and re-reading the code I realized the 1e-20 was to prevent a divide by 0. Obviously there is no division in your proposed code. I'll go ahead and make the change.
Summary: Replace heap allocated nsSVGLength in nsSVGUtils::CoordToFloat with stack allocated nsSVGLength2 → Remove heap allocated nsSVGLength in nsSVGUtils::CoordToFloat
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Whiteboard: [needs landing]
You need to log in before you can comment on or make changes to this bug.