Issue 120788
Summary [libc++] Don't use std::stable_sort in flat_map
Labels libc++
Assignees huixie90
Reporter ldionne
    In `std::flat_map::insert(first, last)`, we currently use `std::stable_sort`. While discussing this with @huixie90 and reading https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2767r2.html#stable-sorting, we agreed that

1. The tree-based associative containers specify that `insert(first, last)` inserts in an unspecified order
2. Not using `std::stable_sort` inside `flat_map` is consistent with that
3. MSVC doesn't use `std::stable_sort` in its implementation
4. Using `std::sort` is usually more efficient than `std::stable_sort`

Since the Standard doesn't require us to sort stably and doing so is more expensive, we should switch to just `std::sort`.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to