Closed Bug 1656924 Opened 5 years ago Closed 5 years ago

nsTArray_Impl::Assign/operator= copying from another array cause code bloat and is inefficient in the infallible case

Categories

(Core :: XPCOM, task)

task

Tracking

()

RESOLVED FIXED
81 Branch
Tracking Status
firefox81 --- fixed

People

(Reporter: sg, Assigned: sg)

References

Details

Attachments

(1 file)

nsTArray_Impl::Assign/operator= copying from another array cause code bloat by using ReplaceElementsAtInternal without exploiting the knowledge that the whole array is being replaced. Since for many instances of the class template, this is the only ReplaceElementsAtInternal call being done, this unnecessary bloats the generated code. Apart from that, it is suboptimal at runtime due to unnecessary checks.

Furthermore, the implementation of ReplaceElementsAtInternal may unnecessarily relocate the existing elements before destroying them if the storage needs to be reallocated. While this could be optimized in ReplaceElementsAtInternal as well, it is simpler to do so in the specialized AssignInternal that is now introduced.

nsTArray_Impl::Assign/operator= copying from another array cause code bloat by
using ReplaceElementsAtInternal without exploiting the knowledge that the whole
array is being replaced. Since for many instances of the class template, this
is the only ReplaceElementsAtInternal call being done, this unnecessary bloats
the generated code. Apart from that, it is suboptimal at runtime due to
unnecessary checks.

Furthermore, the implementation of ReplaceElementsAtInternal may unnecessarily
relocate the existing elements before destroying them if the storage needs to
be reallocated. While this could be optimized in ReplaceElementsAtInternal as
well, it is simpler to do so in the specialized AssignInternal that is now
introduced.

Summary: nsTArray_Impl::Assign/operator= copying from another array cause code bloat → nsTArray_Impl::Assign/operator= copying from another array cause code bloat and is inefficient in the infallible case
Pushed by sgiesecke@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/97ea553e1152 Simplify nsTArray::Assign copying from another array. r=xpcom-reviewers,nika
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → 81 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: