diff options
| author | bing <tanbinghwang@gmail.com> | 2022-04-20 23:11:54 +0800 |
|---|---|---|
| committer | bing <tanbinghwang@gmail.com> | 2022-04-20 23:11:54 +0800 |
| commit | 1b6b802b99a1c0ce575bb80eca6d8f53db20af0a (patch) | |
| tree | f238339dd61710404fab4efa6eaa51a59d7ec17d | |
| parent | 7a73e09e35900703d2d58353f30358cfeb1cb4ea (diff) | |
| download | rust-1b6b802b99a1c0ce575bb80eca6d8f53db20af0a.tar.gz rust-1b6b802b99a1c0ce575bb80eca6d8f53db20af0a.zip | |
Better documentation wording and add known problems section
| -rw-r--r-- | clippy_lints/src/stable_sort_primitive.rs | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/clippy_lints/src/stable_sort_primitive.rs b/clippy_lints/src/stable_sort_primitive.rs index a285323dc6e..a6c685df721 100644 --- a/clippy_lints/src/stable_sort_primitive.rs +++ b/clippy_lints/src/stable_sort_primitive.rs @@ -9,15 +9,25 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { /// ### What it does /// When sorting primitive values (integers, bools, chars, as well - /// as arrays, slices, and tuples of such items), it is better to + /// as arrays, slices, and tuples of such items), it is typically better to /// use an unstable sort than a stable sort. /// /// ### Why is this bad? - /// Using a stable sort consumes more memory and cpu cycles. Because - /// values which compare equal are identical, preserving their + /// Typically, using a stable sort consumes more memory and cpu cycles. + /// Because values which compare equal are identical, preserving their /// relative order (the guarantee that a stable sort provides) means /// nothing, while the extra costs still apply. /// + /// ### Known problems + /// + /// As pointed out in + /// [issue #8241](https://github.com/rust-lang/rust-clippy/issues/8241), + /// a stable sort can instead be significantly faster for certain scenarios + /// (eg. when a sorted vector is extended with new data and resorted). + /// + /// For more information and benchmarking results, please refer to the + /// issue linked above. + /// /// ### Example /// ```rust /// let mut vec = vec![2, 1, 3]; |
