mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-11 08:05:12 +00:00
vec::slice is faster now (Issue #2719)
This commit is contained in:
parent
b19c98ea9a
commit
b837f37d40
@ -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|
|
||||
|
Loading…
Reference in New Issue
Block a user