Closed Bug 1610702 Opened 4 years ago Closed 4 years ago

Support ResizeToFit() for non-pod type in mozilla::Vector

Categories

(Core :: MFBT, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED
mozilla74
Tracking Status
firefox74 --- fixed

People

(Reporter: boris, Assigned: emilio)

References

()

Details

Attachments

(1 file)

See https://phabricator.services.mozilla.com/D60045#inline-367732, we would like to use Vector as the container for StyleTransformOperation and convert it into StyleOwnSliced directly (without any copy). For now, we add an assertion if its capacity is different from its length to make sure we don't leak.

However, the best way is to support something like ResizeToFit() for non-POD types, and then we can drop the assertion.

Probably shrinkStorageToFit or something like that?

And this is not really about leaking, but about Rust allocator requiring the capacity (though I believe mozalloc doesn't) and thus making boxed slices just length == capacity, and OwnedSlice maintaining that. Though it'd be useful more generally I bet.

Flags: needinfo?(emilio)

OK. I see. Thanks for the clarification.

Flags: needinfo?(emilio)
Assignee: nobody → emilio
Status: NEW → ASSIGNED
Pushed by ealvarez@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/f5d0ed5f15d4
Generalize Vector::podResizeToFit into Vector::shrinkStorageToFit(). r=froydnj
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla74
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: