Auto merge of #31914 - bluss:copy-from-slice-everywhere, r=alexcrichton

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.
This commit is contained in:
bors
2016-02-27 01:15:23 +00:00
13 changed files with 23 additions and 18 deletions

View File

@@ -341,7 +341,7 @@ impl Wtf8Buf {
Some((surrogate_pos, _)) => {
pos = surrogate_pos + 3;
self.bytes[surrogate_pos..pos]
.clone_from_slice(UTF8_REPLACEMENT_CHARACTER);
.copy_from_slice(UTF8_REPLACEMENT_CHARACTER);
},
None => return unsafe { String::from_utf8_unchecked(self.bytes) }
}