Create fewer copies in TypedArrayToSorted and ArrayToSorted
Categories
(Core :: JavaScript: Standard Library, enhancement)
Tracking
()
Tracking | Status | |
---|---|---|
firefox105 | --- | fixed |
People
(Reporter: anba, Assigned: anba)
References
(Blocks 1 open bug)
Details
Attachments
(5 files)
TypedArrayToSorted
calls TypedArraySort
, which in turn calls MergeSortTypedArray
. MergeSortTypedArray
creates another copy of the TypedArray, which isn't actually necessary for TypedArrayToSorted
. The same issue applies for ArrayToSorted
.
Assignee | ||
Comment 1•2 years ago
|
||
Change MergeSortTypedArray
to return the sorted array. TypedArraySort
now
needs to copy the sorted elements back into the original array and
TypedArrayToSorted
can directly return the sorted array. When TypedArrayToSorted
is called without a comparator function, we still have to create a copy in
TypedArrayToSorted
which is then passed to TypedArrayNativeSort
. When the
input has fewer than two elements, we only have to copy the input without performing
any sort operations.
Assignee | ||
Comment 2•2 years ago
|
||
Depends on D154261
Assignee | ||
Comment 3•2 years ago
|
||
We generally prefer single-line comments in new code.
Depends on D154262
Assignee | ||
Comment 4•2 years ago
|
||
Inline ArraySort
into ArrayToSorted
in preparation for the next part.
Depends on D154263
Assignee | ||
Comment 5•2 years ago
|
||
Change MergeSort
to directly modify its input instead of creating a copy.
ArraySort
now needs to copy the input and re-arrange any holes, whereas
ArrayToSorted
can directly return the result from MergeSort
.
Depends on D154264
Comment 7•2 years ago
|
||
Backed out for causing SM assertion failures on js/Value.h.
Failure log: https://treeherder.mozilla.org/logviewer?job_id=387128882&repo=autoland
Backout link: https://hg.mozilla.org/integration/autoland/rev/66e3220110ba0dd99ba7d45684ac4731886a59a9
Comment 9•2 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/aef2c47ad1c4
https://hg.mozilla.org/mozilla-central/rev/8ea5622a4264
https://hg.mozilla.org/mozilla-central/rev/61db7e2983a3
https://hg.mozilla.org/mozilla-central/rev/f98b7c864bea
https://hg.mozilla.org/mozilla-central/rev/98f1a8e535e9
Description
•