about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMara Bos <m-ou.se@m-ou.se>2021-08-09 19:25:28 +0200
committerMara Bos <m-ou.se@m-ou.se>2021-08-09 19:25:28 +0200
commit38383017d6bf22ded0af1875e164f0f154285f2f (patch)
tree46c753e7eab32c22fb6cb68e94b623f2caf1f3f0
parenteaf6f463599df1f18da94a6965e216ea15795417 (diff)
downloadrust-38383017d6bf22ded0af1875e164f0f154285f2f.tar.gz
rust-38383017d6bf22ded0af1875e164f0f154285f2f.zip
Remove size_of == 1 case from `fill` specialization.
-rw-r--r--library/core/src/slice/specialize.rs16
1 files changed, 2 insertions, 14 deletions
diff --git a/library/core/src/slice/specialize.rs b/library/core/src/slice/specialize.rs
index 425cf71626f..80eb590587f 100644
--- a/library/core/src/slice/specialize.rs
+++ b/library/core/src/slice/specialize.rs
@@ -1,6 +1,3 @@
-use crate::mem::{size_of, transmute_copy};
-use crate::ptr::write_bytes;
-
 pub(super) trait SpecFill<T> {
     fn spec_fill(&mut self, value: T);
 }
@@ -19,17 +16,8 @@ impl<T: Clone> SpecFill<T> for [T] {
 
 impl<T: Copy> SpecFill<T> for [T] {
     fn spec_fill(&mut self, value: T) {
-        if size_of::<T>() == 1 {
-            // SAFETY: The size_of check above ensures that values are 1 byte wide, as required
-            // for the transmute and write_bytes
-            unsafe {
-                let value: u8 = transmute_copy(&value);
-                write_bytes(self.as_mut_ptr(), value, self.len());
-            }
-        } else {
-            for item in self.iter_mut() {
-                *item = value;
-            }
+        for item in self.iter_mut() {
+            *item = value;
         }
     }
 }