diff options
| author | Ulrik Sverdrup <bluss@users.noreply.github.com> | 2016-02-23 19:25:43 +0100 |
|---|---|---|
| committer | Ulrik Sverdrup <bluss@users.noreply.github.com> | 2016-02-26 14:51:38 +0100 |
| commit | 2d6496dd8432c71b65d67c7216fbd4428c06527b (patch) | |
| tree | e82e379131bb08248dc4d625b19a3a53673957d4 /src/libcore/num | |
| parent | 09130044ce7429beb95742afa7fd371960dbe607 (diff) | |
| download | rust-2d6496dd8432c71b65d67c7216fbd4428c06527b.tar.gz rust-2d6496dd8432c71b65d67c7216fbd4428c06527b.zip | |
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.
Diffstat (limited to 'src/libcore/num')
| -rw-r--r-- | src/libcore/num/flt2dec/mod.rs | 4 |
1 files changed, 2 insertions, 2 deletions
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<usize> { 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 { |
