mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-20 19:04:21 +00:00
A more efficient slice comparison implementation for T: !BytewiseEq
The previous implementation was not optimized properly by the compiler, which didn't leverage the fact that both length were equal.
This commit is contained in:
parent
347452e7e3
commit
5b041abc8c
@ -60,7 +60,17 @@ where
|
||||
return false;
|
||||
}
|
||||
|
||||
self.iter().zip(other.iter()).all(|(x, y)| x == y)
|
||||
// Implemented as explicit indexing rather
|
||||
// than zipped iterators for performance reasons.
|
||||
// See PR https://github.com/rust-lang/rust/pull/116846
|
||||
for idx in 0..self.len() {
|
||||
// bound checks are optimized away
|
||||
if self[idx] != other[idx] {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user