vec::slice is faster now (Issue #2719)

This commit is contained in:
Eric Holk 2012-06-25 17:08:06 -07:00
parent b19c98ea9a
commit b837f37d40

View File

@ -255,18 +255,14 @@ pure fn slice<T: copy>(v: [const T]/&, start: uint, end: uint) -> [T] {
assert (start <= end);
assert (end <= len(v));
let mut result = [];
// unchecked {
// push_all(result, view(v, start, end));
// }
let mut i = start;
while i < end { result += [v[i]]; i += 1u; }
unchecked {
push_all(result, view(v, start, end));
}
ret result;
}
#[doc = "Return a slice that points into another slice."]
pure fn view<T: copy>(v: [const T]/&a, start: uint, end: uint) -> [T]/&a {
pure fn view<T: copy>(v: [const T]/&, start: uint, end: uint) -> [T]/&a {
assert (start <= end);
assert (end <= len(v));
unpack_slice(v) {|p, _len|