Skip to content

Commit ac58641

Browse files
committed
---
yaml --- r: 63755 b: refs/heads/snap-stage3 c: 4470d14 h: refs/heads/master i: 63753: 30f8c89 63751: 2a9d41c v: v3
1 parent 6cd1c75 commit ac58641

File tree

2 files changed

+12
-17
lines changed

2 files changed

+12
-17
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 29b0649a6af8c4821f0d69c544569a9529a68431
4+
refs/heads/snap-stage3: 4470d14388b1637a1e4862c0650baddf6ed7c430
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/libstd/vec.rs

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -438,20 +438,6 @@ pub fn consume_reverse<T>(mut v: ~[T], f: &fn(uint, v: T)) {
438438
}
439439
}
440440

441-
/// Shorten a vector, dropping excess elements.
442-
pub fn truncate<T>(v: &mut ~[T], newlen: uint) {
443-
do as_mut_buf(*v) |p, oldlen| {
444-
assert!(newlen <= oldlen);
445-
unsafe {
446-
// This loop is optimized out for non-drop types.
447-
for uint::range(newlen, oldlen) |i| {
448-
ptr::replace_ptr(ptr::mut_offset(p, i), intrinsics::uninit());
449-
}
450-
}
451-
}
452-
unsafe { raw::set_len(&mut *v, newlen); }
453-
}
454-
455441
/**
456442
* Remove consecutive repeated elements from a vector; if the vector is
457443
* sorted, this removes all duplicates.
@@ -1820,9 +1806,18 @@ impl<T> OwnedVector<T> for ~[T] {
18201806
self.pop()
18211807
}
18221808

1823-
#[inline]
1809+
/// Shorten a vector, dropping excess elements.
18241810
fn truncate(&mut self, newlen: uint) {
1825-
truncate(self, newlen);
1811+
do as_mut_buf(*self) |p, oldlen| {
1812+
assert!(newlen <= oldlen);
1813+
unsafe {
1814+
// This loop is optimized out for non-drop types.
1815+
for uint::range(newlen, oldlen) |i| {
1816+
ptr::replace_ptr(ptr::mut_offset(p, i), intrinsics::uninit());
1817+
}
1818+
}
1819+
}
1820+
unsafe { raw::set_len(self, newlen); }
18261821
}
18271822

18281823
#[inline]

0 commit comments

Comments
 (0)