Closed Bug 1641827 Opened 4 years ago Closed 4 years ago

nsTArray::RemoveLastElement and TruncateLength are unnecessarily complex

Categories

(Core :: XPCOM, task)

task

Tracking

()

RESOLVED FIXED
mozilla79
Tracking Status
firefox79 --- fixed

People

(Reporter: sg, Assigned: sg)

Details

Attachments

(1 file)

The implementation of nsTArray::RemoveLastElement doesn't exploit the static knowledge that only an element at the end of the range is used (and the only necessary safety check is if it is non-empty), but rather uses the generic RemoveElementsAt method. This can be optimized.

Summary: nsTArray::RemoveLastElement is unnecessarily complex → nsTArray::RemoveLastElement and TruncateLength are unnecessarily complex
Assignee: nobody → sgiesecke
Status: NEW → ASSIGNED

The attached patch now uses TruncateLength to implement RemoveLastElement, which suffers from the same issue, and is now changed.

Attachment #9153332 - Attachment description: Bug 1641827 - Simplify implementations of RemoveLastElement and TruncateLength. r=#xpcom-reviewers → Bug 1641827 - Simplify implementations of RemoveLastElement, PopLastElement and TruncateLength. r=#xpcom-reviewers
Attachment #9153332 - Attachment description: Bug 1641827 - Simplify implementations of RemoveLastElement, PopLastElement and TruncateLength. r=#xpcom-reviewers → Bug 1641827 - Simplify implementations of RemoveLastElement and TruncateLength. r=#xpcom-reviewers
Pushed by sgiesecke@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/5c382a535be2
Simplify implementations of RemoveLastElement and TruncateLength. r=froydnj
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla79
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: