Skip to content

Commit 3838301

Browse files
committedAug 9, 2021
Remove size_of == 1 case from fill specialization.
1 parent eaf6f46 commit 3838301

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed
 

‎library/core/src/slice/specialize.rs

+2-14
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
use crate::mem::{size_of, transmute_copy};
2-
use crate::ptr::write_bytes;
3-
41
pub(super) trait SpecFill<T> {
52
fn spec_fill(&mut self, value: T);
63
}
@@ -19,17 +16,8 @@ impl<T: Clone> SpecFill<T> for [T] {
1916

2017
impl<T: Copy> SpecFill<T> for [T] {
2118
fn spec_fill(&mut self, value: T) {
22-
if size_of::<T>() == 1 {
23-
// SAFETY: The size_of check above ensures that values are 1 byte wide, as required
24-
// for the transmute and write_bytes
25-
unsafe {
26-
let value: u8 = transmute_copy(&value);
27-
write_bytes(self.as_mut_ptr(), value, self.len());
28-
}
29-
} else {
30-
for item in self.iter_mut() {
31-
*item = value;
32-
}
19+
for item in self.iter_mut() {
20+
*item = value;
3321
}
3422
}
3523
}

0 commit comments

Comments
 (0)
Please sign in to comment.