Skip to content

Commit 1b6b802

Browse files
author
bing
committed
Better documentation wording and add known problems section
1 parent 7a73e09 commit 1b6b802

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

clippy_lints/src/stable_sort_primitive.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,25 @@ use rustc_session::{declare_lint_pass, declare_tool_lint};
99
declare_clippy_lint! {
1010
/// ### What it does
1111
/// When sorting primitive values (integers, bools, chars, as well
12-
/// as arrays, slices, and tuples of such items), it is better to
12+
/// as arrays, slices, and tuples of such items), it is typically better to
1313
/// use an unstable sort than a stable sort.
1414
///
1515
/// ### Why is this bad?
16-
/// Using a stable sort consumes more memory and cpu cycles. Because
17-
/// values which compare equal are identical, preserving their
16+
/// Typically, using a stable sort consumes more memory and cpu cycles.
17+
/// Because values which compare equal are identical, preserving their
1818
/// relative order (the guarantee that a stable sort provides) means
1919
/// nothing, while the extra costs still apply.
2020
///
21+
/// ### Known problems
22+
///
23+
/// As pointed out in
24+
/// [issue #8241](https://github.com/rust-lang/rust-clippy/issues/8241),
25+
/// a stable sort can instead be significantly faster for certain scenarios
26+
/// (eg. when a sorted vector is extended with new data and resorted).
27+
///
28+
/// For more information and benchmarking results, please refer to the
29+
/// issue linked above.
30+
///
2131
/// ### Example
2232
/// ```rust
2333
/// let mut vec = vec![2, 1, 3];

0 commit comments

Comments
 (0)