Closed Bug 1896745 Opened 8 months ago Closed 8 months ago

Avoid unnecessary refcount traffic when appending DOMRect & PaintRequest to array-of-RefPtrs

Categories

(Core :: DOM: UI Events & Focus Handling, task)

task

Tracking

()

RESOLVED FIXED
128 Branch
Tracking Status
firefox128 --- fixed

People

(Reporter: dholbert, Assigned: dholbert)

Details

Attachments

(1 file)

I noticed some cases where were appending a RefPtr by raw pointer to a nsTArray<RefPtr<...>>, and incurring an extra unnecessary AddRef/Release dance as a result. Filing this bug to clean that up to reduce refcount traffic. Patch incoming.

For these objects, we have an Append(Foo*) method which is just a
wrapper-function that appends to a nsTArray<RefPtr<Foo.>>. As it happens,
every callsite is passing in a local RefPtr variable that's no longer needed
after the call to Append.

It's slightly more performant to use move-semantics to directly transfer
ownership of the existing reference from the local variable to the array,
rather than having the reference count take one step forward and then one step
back, as we were doing before this patch.

Pushed by dholbert@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/6b4cc2f090dc Avoid unnecessary refcount traffic when appending DOMRect & PaintRequest to array-of-RefPtrs. r=mccr8
Status: NEW → RESOLVED
Closed: 8 months ago
Resolution: --- → FIXED
Target Milestone: --- → 128 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: