-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
A-categoryArea: Categorization of lintsArea: Categorization of lintsA-documentationArea: Adding or improving documentationArea: Adding or improving documentationC-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesCategory: Enhancement of lints, like adding more cases or adding help messagesgood first issueThese issues are a good way to get started with ClippyThese issues are a good way to get started with Clippy
Description
Description
The current message for stable_sort_primitive
says:
an unstable sort would perform faster without any observable difference for this data type
for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#stable_sort_primitive
Although it is a reasonable guideline and typically true for random data, it is not always true. For example, the append benchmark in https://gist.github.com/jongiddy/b29ce7d2251775dcf24c595bc245891b demonstrates that stable sort can be significantly faster for a scenario where a sorted vector is extended with new data and resorted.
running 6 tests
test almost_sorted_stable ... bench: 12,290 ns/iter (+/- 97)
test almost_sorted_unstable ... bench: 3,392 ns/iter (+/- 74)
test append_stable ... bench: 2,545 ns/iter (+/- 19)
test append_unstable ... bench: 8,450 ns/iter (+/- 236)
test random_stable ... bench: 16,803 ns/iter (+/- 396)
test random_unstable ... bench: 6,149 ns/iter (+/- 156)
Because of this, the initial message should be less definite:
an unstable sort typically performs faster without any observable difference for this data type
for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#stable_sort_primitive
and the linked message should also be less definite, and suggest benchmarking specific situations.
Version
No response
Additional Labels
No response
PatchMixolydic
Metadata
Metadata
Assignees
Labels
A-categoryArea: Categorization of lintsArea: Categorization of lintsA-documentationArea: Adding or improving documentationArea: Adding or improving documentationC-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesCategory: Enhancement of lints, like adding more cases or adding help messagesgood first issueThese issues are a good way to get started with ClippyThese issues are a good way to get started with Clippy