From 2d6496dd8432c71b65d67c7216fbd4428c06527b Mon Sep 17 00:00:00 2001 From: Ulrik Sverdrup Date: Tue, 23 Feb 2016 19:25:43 +0100 Subject: Use .copy_from_slice() where applicable .copy_from_slice() does the same job of .clone_from_slice(), but the former is explicitly for Copy elements and calls `memcpy` directly, and thus is it efficient without optimization too. --- src/libcore/num/flt2dec/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/libcore/num') diff --git a/src/libcore/num/flt2dec/mod.rs b/src/libcore/num/flt2dec/mod.rs index 9f7672a52a1..b9a7afc400d 100644 --- a/src/libcore/num/flt2dec/mod.rs +++ b/src/libcore/num/flt2dec/mod.rs @@ -210,7 +210,7 @@ impl<'a> Part<'a> { } } Part::Copy(buf) => { - out[..buf.len()].clone_from_slice(buf); + out[..buf.len()].copy_from_slice(buf); } } Some(len) @@ -245,7 +245,7 @@ impl<'a> Formatted<'a> { /// (It may still leave partially written bytes in the buffer; do not rely on that.) pub fn write(&self, out: &mut [u8]) -> Option { if out.len() < self.sign.len() { return None; } - out[..self.sign.len()].clone_from_slice(self.sign); + out[..self.sign.len()].copy_from_slice(self.sign); let mut written = self.sign.len(); for part in self.parts { -- cgit 1.4.1-3-g733a5