Skip to content

Commit 32e607d

Browse files
Rollup merge of rust-lang#43374 - stjepang:fix-sort-randomization-comment, r=alexcrichton
Clarify that sort_unstable is deterministic @frankmcsherry complained that the documentation said "it is randomized but deterministic", which is a contradictory statement. This PR uses a different and clearer wording.
2 parents f1537da + 9a51055 commit 32e607d

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

src/liballoc/slice.rs

+18-15
Original file line numberDiff line numberDiff line change
@@ -1252,12 +1252,13 @@ impl<T> [T] {
12521252
///
12531253
/// # Current implementation
12541254
///
1255-
/// The current algorithm is based on Orson Peters' [pattern-defeating quicksort][pdqsort],
1256-
/// which is a quicksort variant designed to be very fast on certain kinds of patterns,
1257-
/// sometimes achieving linear time. It is randomized but deterministic, and falls back to
1258-
/// heapsort on degenerate inputs.
1255+
/// The current algorithm is based on [pattern-defeating quicksort][pdqsort] by Orson Peters,
1256+
/// which combines the fast average case of randomized quicksort with the fast worst case of
1257+
/// heapsort, while achieving linear time on slices with certain patterns. It uses some
1258+
/// randomization to avoid degenerate cases, but with a fixed seed to always provide
1259+
/// deterministic behavior.
12591260
///
1260-
/// It is generally faster than stable sorting, except in a few special cases, e.g. when the
1261+
/// It is typically faster than stable sorting, except in a few special cases, e.g. when the
12611262
/// slice consists of several concatenated sorted sequences.
12621263
///
12631264
/// # Examples
@@ -1286,12 +1287,13 @@ impl<T> [T] {
12861287
///
12871288
/// # Current implementation
12881289
///
1289-
/// The current algorithm is based on Orson Peters' [pattern-defeating quicksort][pdqsort],
1290-
/// which is a quicksort variant designed to be very fast on certain kinds of patterns,
1291-
/// sometimes achieving linear time. It is randomized but deterministic, and falls back to
1292-
/// heapsort on degenerate inputs.
1290+
/// The current algorithm is based on [pattern-defeating quicksort][pdqsort] by Orson Peters,
1291+
/// which combines the fast average case of randomized quicksort with the fast worst case of
1292+
/// heapsort, while achieving linear time on slices with certain patterns. It uses some
1293+
/// randomization to avoid degenerate cases, but with a fixed seed to always provide
1294+
/// deterministic behavior.
12931295
///
1294-
/// It is generally faster than stable sorting, except in a few special cases, e.g. when the
1296+
/// It is typically faster than stable sorting, except in a few special cases, e.g. when the
12951297
/// slice consists of several concatenated sorted sequences.
12961298
///
12971299
/// # Examples
@@ -1323,12 +1325,13 @@ impl<T> [T] {
13231325
///
13241326
/// # Current implementation
13251327
///
1326-
/// The current algorithm is based on Orson Peters' [pattern-defeating quicksort][pdqsort],
1327-
/// which is a quicksort variant designed to be very fast on certain kinds of patterns,
1328-
/// sometimes achieving linear time. It is randomized but deterministic, and falls back to
1329-
/// heapsort on degenerate inputs.
1328+
/// The current algorithm is based on [pattern-defeating quicksort][pdqsort] by Orson Peters,
1329+
/// which combines the fast average case of randomized quicksort with the fast worst case of
1330+
/// heapsort, while achieving linear time on slices with certain patterns. It uses some
1331+
/// randomization to avoid degenerate cases, but with a fixed seed to always provide
1332+
/// deterministic behavior.
13301333
///
1331-
/// It is generally faster than stable sorting, except in a few special cases, e.g. when the
1334+
/// It is typically faster than stable sorting, except in a few special cases, e.g. when the
13321335
/// slice consists of several concatenated sorted sequences.
13331336
///
13341337
/// # Examples

0 commit comments

Comments
 (0)