nsTArray::Sort uses non-templated NS_QuickSort function where each comparison is a non-inlined function call
Categories
(Core :: XPCOM, defect)
Tracking
()
People
(Reporter: bjacob, Unassigned)
References
Details
Attachments
(1 file)
1.22 KB,
patch
|
Details | Diff | Splinter Review |
![]() |
||
Comment 1•10 years ago
|
||
Reporter | ||
Comment 2•10 years ago
|
||
Reporter | ||
Comment 3•10 years ago
|
||
![]() |
||
Comment 4•10 years ago
|
||
Reporter | ||
Comment 5•10 years ago
|
||
Comment 6•5 years ago
|
||
I'd like to give that a heads up, given that the modern libstdc++ implementation uses introsort, which has optimal worst-case performance as opposed to quicksort?
(I have seen arguments that don't want to use Sort
but rather a loop doing InsertElementSorted
, because that might be faster for small N, which doesn't seem like a good situation.)
Can we just see how changing from NS_QuickSort
to std::sort
affects the code size, and then think again if the effect is so bad that is warrants to keep using the non-templated sort? It's not even necessarily the case that every instance of the template generates distinct code, even for different template parameters.
Comment 7•5 years ago
|
||
It turns out that replacing NS_QuickSort
by std::sort
in nsTArray_Impl::Sort
is not that trivial, since apparently that's used with types that are not (move-)assignable, which is a requirement for std::sort
. OTOH, that lead me to the insight that nsTArray_Impl::Sort
uses memutils even for types that use MOZ_DECLARE_RELOCATE_USING_MOVE_CONSTRUCTOR
, which is a defect. (But I am not yet sure if sorting is done for any such element type)
Updated•2 years ago
|
Updated•11 months ago
|
Description
•