@@ -1081,8 +1081,7 @@ impl<T, C: Compare<T>> BinaryHeap<T, C> {
1081
1081
// it's a valid index and also != hole.pos().
1082
1082
if self
1083
1083
. cmp
1084
- . compare ( hole. element ( ) , unsafe { hole. get ( parent) } )
1085
- != Ordering :: Greater
1084
+ . compares_le ( hole. element ( ) , unsafe { hole. get ( parent) } )
1086
1085
{
1087
1086
break ;
1088
1087
}
@@ -1114,14 +1113,15 @@ impl<T, C: Compare<T>> BinaryHeap<T, C> {
1114
1113
// child + 1 == 2 * hole.pos() + 2 != hole.pos().
1115
1114
// FIXME: 2 * hole.pos() + 1 or 2 * hole.pos() + 2 could overflow
1116
1115
// if T is a ZST
1117
- child += unsafe {
1118
- self . cmp . compare ( hole. get ( child) , hole. get ( child + 1 ) ) != Ordering :: Greater
1119
- } as usize ;
1116
+ child += unsafe { self . cmp . compares_le ( hole. get ( child) , hole. get ( child + 1 ) ) } as usize ;
1120
1117
1121
1118
// if we are already in order, stop.
1122
1119
// SAFETY: child is now either the old child or the old child+1
1123
1120
// We already proven that both are < self.len() and != hole.pos()
1124
- if self . cmp . compare ( hole. element ( ) , unsafe { hole. get ( child) } ) != Ordering :: Less {
1121
+ if self
1122
+ . cmp
1123
+ . compares_ge ( hole. element ( ) , unsafe { hole. get ( child) } )
1124
+ {
1125
1125
return ;
1126
1126
}
1127
1127
@@ -1133,7 +1133,9 @@ impl<T, C: Compare<T>> BinaryHeap<T, C> {
1133
1133
// SAFETY: && short circuit, which means that in the
1134
1134
// second condition it's already true that child == end - 1 < self.len().
1135
1135
if child == end - 1
1136
- && self . cmp . compare ( hole. element ( ) , unsafe { hole. get ( child) } ) == Ordering :: Less
1136
+ && self
1137
+ . cmp
1138
+ . compares_lt ( hole. element ( ) , unsafe { hole. get ( child) } )
1137
1139
{
1138
1140
// SAFETY: child is already proven to be a valid index and
1139
1141
// child == 2 * hole.pos() + 1 != hole.pos().
@@ -1176,9 +1178,7 @@ impl<T, C: Compare<T>> BinaryHeap<T, C> {
1176
1178
// child + 1 == 2 * hole.pos() + 2 != hole.pos().
1177
1179
// FIXME: 2 * hole.pos() + 1 or 2 * hole.pos() + 2 could overflow
1178
1180
// if T is a ZST
1179
- child += unsafe {
1180
- self . cmp . compare ( hole. get ( child) , hole. get ( child + 1 ) ) != Ordering :: Greater
1181
- } as usize ;
1181
+ child += unsafe { self . cmp . compares_le ( hole. get ( child) , hole. get ( child + 1 ) ) } as usize ;
1182
1182
1183
1183
// SAFETY: Same as above
1184
1184
unsafe { hole. move_to ( child) } ;
0 commit comments