]> git.lizzy.rs Git - rust.git/commitdiff
std::vec: convert .copy_memory to use copy_nonoverlapping_memory.
authorHuon Wilson <dbau.pp+github@gmail.com>
Mon, 16 Dec 2013 13:31:59 +0000 (00:31 +1100)
committerHuon Wilson <dbau.pp+github@gmail.com>
Mon, 16 Dec 2013 21:36:04 +0000 (08:36 +1100)
It is required that &mut[]s are disjoint from all other &(mut)[]s, so
this assumption is ok.

src/libstd/vec.rs

index a0c94e6810acabc13d7364aec6bc041a2d4805d5..2a0f575cddec9e5552c7376e06fda20c627eff1a 100644 (file)
@@ -2060,7 +2060,7 @@ fn mut_split_at(self, mid: uint) -> (&'a mut [T],
      */
     unsafe fn init_elem(self, i: uint, val: T);
 
-    /// Copies data from `src` to `self`
+    /// Copies data from `src` to `self`.
     ///
     /// `self` and `src` must not overlap. Fails if `self` is
     /// shorter than `src`.
@@ -2208,7 +2208,7 @@ unsafe fn copy_memory(self, src: &[T]) {
         self.as_mut_buf(|p_dst, len_dst| {
             src.as_imm_buf(|p_src, len_src| {
                 assert!(len_dst >= len_src)
-                ptr::copy_memory(p_dst, p_src, len_src)
+                ptr::copy_nonoverlapping_memory(p_dst, p_src, len_src)
             })
         })
     }
@@ -2350,10 +2350,10 @@ fn set_memory(self, value: u8) {
         }
     }
 
-    /// Copies data from one vector to another.
+    /// Copies data from `src` to `dst`
     ///
-    /// Copies `src` to `dst`. Fails if the length of `dst` is less
-    /// than the length of `src`.
+    /// `src` and `dst` must not overlap. Fails if the length of `dst`
+    /// is less than the length of `src`.
     #[inline]
     pub fn copy_memory(dst: &mut [u8], src: &[u8]) {
         // Bound checks are done at .copy_memory.