use swap_unchecked
in slice::reverse
This commit is contained in:
parent
14769ce96f
commit
33ecc33268
1 changed files with 1 additions and 5 deletions
|
@ -707,11 +707,7 @@ impl<T> [T] {
|
||||||
// The resulting pointers `pa` and `pb` are therefore valid and
|
// The resulting pointers `pa` and `pb` are therefore valid and
|
||||||
// aligned, and can be read from and written to.
|
// aligned, and can be read from and written to.
|
||||||
unsafe {
|
unsafe {
|
||||||
// Unsafe swap to avoid the bounds check in safe swap.
|
self.swap_unchecked(i, ln - i - 1);
|
||||||
let ptr = self.as_mut_ptr();
|
|
||||||
let pa = ptr.add(i);
|
|
||||||
let pb = ptr.add(ln - i - 1);
|
|
||||||
ptr::swap(pa, pb);
|
|
||||||
}
|
}
|
||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue