Skip to content

Commit 98e97a4

Browse files
committed
Address review comments
1 parent 53686b9 commit 98e97a4

File tree

3 files changed

+13
-42
lines changed

3 files changed

+13
-42
lines changed

src/libcore/ptr/const_ptr.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ impl<T: ?Sized> *const T {
295295
intrinsics::ptr_offset_from(self, origin)
296296
}
297297

298-
/// Returns whether two pointers are guaranteed equal.
298+
/// Returns whether two pointers are guaranteed to be equal.
299299
///
300300
/// At runtime this function behaves like `self == other`.
301301
/// However, in some contexts (e.g., compile-time evaluation),
@@ -328,7 +328,7 @@ impl<T: ?Sized> *const T {
328328
intrinsics::ptr_guaranteed_eq(self, other)
329329
}
330330

331-
/// Returns whether two pointers are guaranteed not equal.
331+
/// Returns whether two pointers are guaranteed to be inequal.
332332
///
333333
/// At runtime this function behaves like `self != other`.
334334
/// However, in some contexts (e.g., compile-time evaluation),

src/libcore/ptr/mut_ptr.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ impl<T: ?Sized> *mut T {
273273
if self.is_null() { None } else { Some(&mut *self) }
274274
}
275275

276-
/// Returns whether two pointers are guaranteed equal.
276+
/// Returns whether two pointers are guaranteed to be equal.
277277
///
278278
/// At runtime this function behaves like `self == other`.
279279
/// However, in some contexts (e.g., compile-time evaluation),
@@ -306,7 +306,7 @@ impl<T: ?Sized> *mut T {
306306
intrinsics::ptr_guaranteed_eq(self as *const _, other as *const _)
307307
}
308308

309-
/// Returns whether two pointers are guaranteed not equal.
309+
/// Returns whether two pointers are guaranteed to be inequal.
310310
///
311311
/// At runtime this function behaves like `self != other`.
312312
/// However, in some contexts (e.g., compile-time evaluation),

src/libcore/slice/mod.rs

+9-38
Original file line numberDiff line numberDiff line change
@@ -5946,8 +5946,7 @@ where
59465946
}
59475947
}
59485948

5949-
// Remove after boostrap bump
5950-
#[cfg(bootstrap)]
5949+
// Use an equal-pointer optimization when types are `Eq`
59515950
impl<A> SlicePartialEq<A> for [A]
59525951
where
59535952
A: PartialEq<A> + Eq,
@@ -5957,47 +5956,14 @@ where
59575956
return false;
59585957
}
59595958

5959+
#[cfg(bootstrap)]
59605960
if self.as_ptr() == other.as_ptr() {
59615961
return true;
59625962
}
59635963

5964-
self.iter().zip(other.iter()).all(|(x, y)| x == y)
5965-
}
5966-
}
5967-
5968-
// Remove after boostrap bump
5969-
#[cfg(bootstrap)]
5970-
impl<A> SlicePartialEq<A> for [A]
5971-
where
5972-
A: PartialEq<A> + BytewiseEquality,
5973-
{
5974-
fn equal(&self, other: &[A]) -> bool {
5975-
if self.len() != other.len() {
5976-
return false;
5977-
}
5978-
if self.as_ptr() == other.as_ptr() {
5979-
return true;
5980-
}
5981-
unsafe {
5982-
let size = mem::size_of_val(self);
5983-
memcmp(self.as_ptr() as *const u8, other.as_ptr() as *const u8, size) == 0
5984-
}
5985-
}
5986-
}
5987-
5988-
// Use an equal-pointer optimization when types are `Eq`
5989-
#[cfg(not(bootstrap))]
5990-
impl<A> SlicePartialEq<A> for [A]
5991-
where
5992-
A: PartialEq<A> + Eq,
5993-
{
5994-
default fn equal(&self, other: &[A]) -> bool {
5995-
if self.len() != other.len() {
5996-
return false;
5997-
}
5998-
59995964
// While performance would suffer if `guaranteed_eq` just returned `false`
60005965
// for all arguments, correctness and return value of this function are not affected.
5966+
#[cfg(not(bootstrap))]
60015967
if self.as_ptr().guaranteed_eq(other.as_ptr()) {
60025968
return true;
60035969
}
@@ -6007,7 +5973,6 @@ where
60075973
}
60085974

60095975
// Use memcmp for bytewise equality when the types allow
6010-
#[cfg(not(bootstrap))]
60115976
impl<A> SlicePartialEq<A> for [A]
60125977
where
60135978
A: PartialEq<A> + BytewiseEquality,
@@ -6017,8 +5982,14 @@ where
60175982
return false;
60185983
}
60195984

5985+
#[cfg(bootstrap)]
5986+
if self.as_ptr() == other.as_ptr() {
5987+
return true;
5988+
}
5989+
60205990
// While performance would suffer if `guaranteed_eq` just returned `false`
60215991
// for all arguments, correctness and return value of this function are not affected.
5992+
#[cfg(not(bootstrap))]
60225993
if self.as_ptr().guaranteed_eq(other.as_ptr()) {
60235994
return true;
60245995
}

0 commit comments

Comments
 (0)