From 5e9e73cc9f9c3f8230af739ec4d234f4d99842b2 Mon Sep 17 00:00:00 2001 From: Warrenren <50134367+Warrenren@users.noreply.github.com> Date: Fri, 10 Jun 2022 19:08:03 +0800 Subject: [PATCH 1/2] line 1352, change self to (*self), other to (*other) The current code will not results bug, but it difficult to understand. These code result to call &f32::partial_cmp(), and the performance will be lower than the changed code. I'm not sure why the current code don't use (*self) (*other), if you have some idea, please let me know. --- library/core/src/cmp.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/src/cmp.rs b/library/core/src/cmp.rs index f281e8429c69..353dd74ba890 100644 --- a/library/core/src/cmp.rs +++ b/library/core/src/cmp.rs @@ -1349,7 +1349,7 @@ mod impls { impl PartialOrd for $t { #[inline] fn partial_cmp(&self, other: &$t) -> Option { - match (self <= other, self >= other) { + match ((*self) <= (*other), (*self) >= (*other)) { (false, false) => None, (false, true) => Some(Greater), (true, false) => Some(Less), From 9e1e4761862a875562a87631466e96a8c1ebab83 Mon Sep 17 00:00:00 2001 From: Warrenren <50134367+Warrenren@users.noreply.github.com> Date: Sat, 11 Jun 2022 11:04:27 +0800 Subject: [PATCH 2/2] Update cmp.rs line 1352, delete parentheses for reviewers asking for it. --- library/core/src/cmp.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/src/cmp.rs b/library/core/src/cmp.rs index 353dd74ba890..81aed8afd5b5 100644 --- a/library/core/src/cmp.rs +++ b/library/core/src/cmp.rs @@ -1349,7 +1349,7 @@ mod impls { impl PartialOrd for $t { #[inline] fn partial_cmp(&self, other: &$t) -> Option { - match ((*self) <= (*other), (*self) >= (*other)) { + match (*self <= *other, *self >= *other) { (false, false) => None, (false, true) => Some(Greater), (true, false) => Some(Less),