提交 b837f37d 编写于 作者: E Eric Holk

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

上级 b19c98ea
......@@ -255,18 +255,14 @@ fn from_mut<T>(+v: [mut T]) -> [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|
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册