Closed Bug 473517 Opened 16 years ago Closed 16 years ago

Remove heap allocated nsSVGLength in nsSVGUtils::CoordToFloat

Categories

(Core :: SVG, defect)

defect
Not set
trivial

Tracking

()

RESOLVED FIXED

People

(Reporter: craig.topper, Assigned: craig.topper)

Details

Attachments

(1 file, 1 obsolete file)

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.
Attached patch Patch (obsolete) — Splinter Review
Attachment #357090 - Flags: review?(roc)
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.
Attachment #357090 - Attachment is obsolete: true
Attachment #357120 - Flags: review?(roc)
Keywords: checkin-needed
Whiteboard: [needs landing]
Summary: Replace heap allocated nsSVGLength in nsSVGUtils::CoordToFloat with stack allocated nsSVGLength2 → Remove heap allocated nsSVGLength in nsSVGUtils::CoordToFloat
Pushed http://hg.mozilla.org/mozilla-central/rev/07c89c67e4b9
Status: NEW → RESOLVED
Closed: 16 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Whiteboard: [needs landing]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: