Just a note (taken from a chat with Jari): There might be a potential for a footgun here if the T in `nsTArray<RefPtr<T>>` `HasThreadSafeRefCnt` as this might indicate that elements (and thus their comparator result) could change while sorting. As nsTArray itself is not thread safe, this is probably true also for the old sort implementation. With the current state of things we could probably just issue a warning or (static) assert if we want to sort such a T. But all accesses through `nsTArray` to such T would need to happen under some lock managed elsewhere, anyways, and thus also sorting, IMHO.
Bug 1842130 Comment 6 Edit History
Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.
Just a note (taken from a chat with Jari): There might be a potential for a footgun here if the T in `nsTArray<RefPtr<T>>` `HasThreadSafeRefCnt` as this might indicate that elements (and thus their comparator result) could change while sorting. Note that at least the refcount should remain always >0 as the array element holds one while sorting. As nsTArray itself is not thread safe, this is probably true also for the old sort implementation. With the current state of things we could probably just issue a warning or (static) assert if we want to sort such a T. But all accesses through `nsTArray` to such T would need to happen under some lock managed elsewhere, anyways, and thus also sorting, IMHO.