Rollup merge of #33892 - seanmonstar:slice-eq-ptr, r=alexcrichton

core: check pointer equality when comparing byte slices

If pointer address and length are the same, it should be the same slice.

In experiments, I've seen that this doesn't happen as often in debug builds, but release builds seem to optimize to using a single pointer more often.
This commit is contained in:
Manish Goregaokar 2016-06-01 12:57:41 +05:30
commit 7694e18d43

View file

@ -1830,6 +1830,9 @@ impl<A> SlicePartialEq<A> for [A]
if self.len() != other.len() {
return false;
}
if self.as_ptr() == other.as_ptr() {
return true;
}
unsafe {
let size = mem::size_of_val(self);
memcmp(self.as_ptr() as *const u8,