Skip to content

Commit b837f37

Browse files
committed
vec::slice is faster now (Issue #2719)
1 parent b19c98e commit b837f37

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/libcore/vec.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -255,18 +255,14 @@ pure fn slice<T: copy>(v: [const T]/&, start: uint, end: uint) -> [T] {
255255
assert (start <= end);
256256
assert (end <= len(v));
257257
let mut result = [];
258-
259-
// unchecked {
260-
// push_all(result, view(v, start, end));
261-
// }
262-
263-
let mut i = start;
264-
while i < end { result += [v[i]]; i += 1u; }
258+
unchecked {
259+
push_all(result, view(v, start, end));
260+
}
265261
ret result;
266262
}
267263

268264
#[doc = "Return a slice that points into another slice."]
269-
pure fn view<T: copy>(v: [const T]/&a, start: uint, end: uint) -> [T]/&a {
265+
pure fn view<T: copy>(v: [const T]/&, start: uint, end: uint) -> [T]/&a {
270266
assert (start <= end);
271267
assert (end <= len(v));
272268
unpack_slice(v) {|p, _len|

0 commit comments

Comments
 (0)