Closed Bug 1650245 Opened 4 years ago Closed 4 years ago

Use nsTArray::StableSort in CSSOrderAwareFrameIteratorT

Categories

(Core :: Layout, task)

task

Tracking

()

RESOLVED FIXED
mozilla80
Tracking Status
firefox80 --- fixed

People

(Reporter: TYLin, Assigned: TYLin)

References

Details

Attachments

(3 files)

Let's fix this

// XXX replace this with nsTArray::StableSort when bug 1147091 is fixed.
std::stable_sort(mArray->begin(), mArray->end(), comparator);

https://searchfox.org/mozilla-central/rev/31d8600b73dc85b4cdbabf45ac3f1a9c11700d8e/layout/generic/CSSOrderAwareFrameIterator.h#115-116

I also spot some minor improvements in CSSOrderAwareFrameIteratorT.

Both methods are implementation details specific to this iterator, not
public interfaces that can be cooperated with C++ standard library, so
move them into private section.

nsTArray::StableSort() requires the Comparator to be a class/struct with
Equals() and LessThan() members. This patch adapts the original
comparators to fulfill this contract.

Using StableSort() can also avoid the array bound checking in the array
iterator as described in bug 1147091 comment 8.

Change the include to <limits> because std::stable_sort is removed but
we still use std::numeric_limits.

Depends on D82117

Pushed by aethanyc@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/7d9b58a4da5c
Part 1 - Move begin() and end() into private section in CSSOrderAwareFrameIterator. r=dholbert
https://hg.mozilla.org/integration/autoland/rev/a0aef12f15c1
Part 2 - Use nsTArray::StableSort() in CSSOrderAwareFrameIteratorT. r=dholbert,sg
https://hg.mozilla.org/integration/autoland/rev/193197448f03
Part 3 - Remove CLANG_CRASH_BUG define in CSSOrderAwareFrameIterator.h. r=dholbert
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla80
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: