rust/library/core/benches
bors 816f958ac3 Auto merge of #108157 - scottmcm:tuple-gt-via-partialcmp, r=dtolnay
Use `partial_cmp` to implement tuple `lt`/`le`/`ge`/`gt`

In today's implementation, `(A, B)::gt` contains calls to *both* `A::eq` *and* `A::gt`.

That's fine for primitives, but for things like `String`s it's kinda weird -- `(String, usize)::gt` has a call to both `bcmp` and `memcmp` (<https://rust.godbolt.org/z/7jbbPMesf>) because when `bcmp` says the `String`s aren't equal, it turns around and calls `memcmp` to find out which one's bigger.

This PR changes the implementation to instead implement `(A, …, C, Z)::gt` using `A::partial_cmp`, `…::partial_cmp`, `C::partial_cmp`, and `Z::gt`.  (And analogously for `lt`, `le`, and `ge`.)  That way expensive comparisons don't need to be repeated.

Technically this is an observable change on stable, so I've marked it `needs-fcp` + `T-libs-api` and will
r? rust-lang/libs-api

I'm hoping that this will be non-controversial, however, since it's very similar to the observable changes that were made to the derives (#81384 #98655) -- like those, this only changes behaviour if a type overrode behaviour in a way inconsistent with the rules for the various traits involved.

(The first commit here is #108156, adding the codegen test, which I used to make sure this doesn't regress behaviour for primitives.)

Zulip conversation about this change: <https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/.60.3E.60.20on.20Tuples/near/328392927>.
2023-03-05 22:02:26 +00:00
..
ascii Make some usize-typed masks definition agnostic to the size of usize 2022-04-15 17:04:59 +02:00
char fix #107590, Fix benchmarks in library/core with black_box 2023-02-03 00:33:36 +08:00
hash mv std libs to library/ 2020-07-27 19:51:13 -05:00
num fix #107590, Fix benchmarks in library/core with black_box 2023-02-03 00:33:36 +08:00
str Respond to review feedback, and improve implementation somewhat 2022-02-05 11:15:18 -08:00
any.rs mv std libs to library/ 2020-07-27 19:51:13 -05:00
array.rs Shrink size of array benchmarks 2023-02-14 05:01:24 +00:00
ascii.rs Unify way to flip 6th bit. (Same assembly generated) 2021-02-08 12:21:36 +00:00
fmt.rs Add unicode fast path to is_printable 2022-05-31 10:51:35 +02:00
iter.rs add benchmark for iter::ArrayChunks::fold specialization 2022-11-07 21:44:24 +01:00
lib.rs Add a slightly-contrived tuple comparison benchmark 2023-02-17 11:46:19 -08:00
ops.rs mv std libs to library/ 2020-07-27 19:51:13 -05:00
pattern.rs mv std libs to library/ 2020-07-27 19:51:13 -05:00
slice.rs Stop manually SIMDing in swap_nonoverlapping 2022-02-21 00:54:02 -08:00
str.rs Optimize core::str::Chars::count 2022-02-05 11:15:17 -08:00
tuple.rs Add a slightly-contrived tuple comparison benchmark 2023-02-17 11:46:19 -08:00