Skip to content

Commit c9418c5

Browse files
committed
---
yaml --- r: 147292 b: refs/heads/try2 c: d0ae820 h: refs/heads/master v: v3
1 parent 387832e commit c9418c5

File tree

3 files changed

+23
-24
lines changed

3 files changed

+23
-24
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: ad20a78c548819b6671ee11eed7501e61429575a
8+
refs/heads/try2: d0ae820765dbdbb941ee7f3a08aec895616b4db5
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libextra/uuid.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,7 @@ impl Uuid {
219219
}
220220

221221
let mut uuid = Uuid{ bytes: [0, .. 16] };
222-
unsafe {
223-
vec::raw::copy_memory(uuid.bytes, b);
224-
}
222+
vec::bytes::copy_memory(uuid.bytes, b);
225223
Some(uuid)
226224
}
227225

branches/try2/src/libstd/vec.rs

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2060,6 +2060,12 @@ pub trait MutableVector<'a, T> {
20602060
*/
20612061
unsafe fn init_elem(self, i: uint, val: T);
20622062

2063+
/// Copies data from `src` to `self`
2064+
///
2065+
/// `self` and `src` must not overlap. Fails if `self` is
2066+
/// shorter than `src`.
2067+
unsafe fn copy_memory(self, src: &[T]);
2068+
20632069
/// Similar to `as_imm_buf` but passing a `*mut T`
20642070
fn as_mut_buf<U>(self, f: |*mut T, uint| -> U) -> U;
20652071
}
@@ -2197,6 +2203,16 @@ impl<'a,T> MutableVector<'a, T> for &'a mut [T] {
21972203
})
21982204
}
21992205

2206+
#[inline]
2207+
unsafe fn copy_memory(self, src: &[T]) {
2208+
self.as_mut_buf(|p_dst, len_dst| {
2209+
src.as_imm_buf(|p_src, len_src| {
2210+
assert!(len_dst >= len_src)
2211+
ptr::copy_memory(p_dst, p_src, len_src)
2212+
})
2213+
})
2214+
}
2215+
22002216
#[inline]
22012217
fn as_mut_buf<U>(self, f: |*mut T, uint| -> U) -> U {
22022218
let Slice{ data, len } = self.repr();
@@ -2238,7 +2254,7 @@ pub unsafe fn from_buf<T>(ptr: *T, elts: uint) -> ~[T] {
22382254
pub mod raw {
22392255
use cast;
22402256
use ptr;
2241-
use vec::{with_capacity, ImmutableVector, MutableVector};
2257+
use vec::{with_capacity, MutableVector};
22422258
use unstable::raw::Slice;
22432259

22442260
/**
@@ -2288,21 +2304,6 @@ pub mod raw {
22882304
dst
22892305
}
22902306

2291-
/**
2292-
* Copies data from one vector to another.
2293-
*
2294-
* Copies `src` to `dst`. The source and destination may overlap.
2295-
*/
2296-
#[inline]
2297-
pub unsafe fn copy_memory<T>(dst: &mut [T], src: &[T]) {
2298-
dst.as_mut_buf(|p_dst, len_dst| {
2299-
src.as_imm_buf(|p_src, len_src| {
2300-
assert!(len_dst >= len_src)
2301-
ptr::copy_memory(p_dst, p_src, len_src)
2302-
})
2303-
})
2304-
}
2305-
23062307
/**
23072308
* Returns a pointer to first element in slice and adjusts
23082309
* slice so it no longer contains that element. Fails if
@@ -2331,7 +2332,7 @@ pub mod raw {
23312332

23322333
/// Operations on `[u8]`.
23332334
pub mod bytes {
2334-
use vec::raw;
2335+
use vec::MutableVector;
23352336
use ptr;
23362337

23372338
/// A trait for operations on mutable `[u8]`s.
@@ -2358,8 +2359,8 @@ pub mod bytes {
23582359
*/
23592360
#[inline]
23602361
pub fn copy_memory(dst: &mut [u8], src: &[u8]) {
2361-
// Bound checks are done at vec::raw::copy_memory.
2362-
unsafe { raw::copy_memory(dst, src) }
2362+
// Bound checks are done at .copy_memory.
2363+
unsafe { dst.copy_memory(src) }
23632364
}
23642365

23652366
/**
@@ -3585,7 +3586,7 @@ mod tests {
35853586
unsafe {
35863587
let mut a = [1, 2, 3, 4];
35873588
let b = [1, 2, 3, 4, 5];
3588-
raw::copy_memory(a, b);
3589+
a.copy_memory(b);
35893590
}
35903591
}
35913592

0 commit comments

Comments
 (0)