Skip to content

Commit 3bacce0

Browse files
committed
---
yaml --- r: 13958 b: refs/heads/try c: 694de53 h: refs/heads/master v: v3
1 parent ceac46d commit 3bacce0

File tree

2 files changed

+5
-14
lines changed

2 files changed

+5
-14
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
refs/heads/master: 61b1875c16de39c166b0f4d54bba19f9c6777d1a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5-
refs/heads/try: 2dbaa05af8f2aeef709712725e103836405fa5f5
5+
refs/heads/try: 694de53d281b5bdf3d187749cca9badf9063cd21
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/try/src/libcore/vec.rs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -294,27 +294,18 @@ fn shift<T: copy>(&v: [const T]) -> T {
294294
ret e;
295295
}
296296

297-
// TODO: Write this, unsafely, in a way that's not O(n).
298297
/*
299298
Function: pop
300299
301300
Remove the last element from a vector and return it
302301
*/
303-
fn pop<T: copy>(&v: [const T]) -> T {
302+
fn pop<T>(&v: [const T]) -> T unsafe {
304303
let ln = len(v);
305-
assert (ln > 0u);
306-
ln -= 1u;
307-
let e = v[ln];
308-
v = slice(v, 0u, ln);
309-
ret e;
310-
// FIXME use this implementation after the next snapshot (27.01.2012)
311-
/* let new_ln = len(v) - 1u;
312-
assert (new_ln > 0u);
313-
let valptr = ptr::mut_addr_of(v[new_ln]);
304+
assert ln > 0u;
305+
let valptr = ptr::mut_addr_of(v[ln - 1u]);
314306
let val <- *valptr;
315-
unsafe::set_len(v, new_ln);
307+
unsafe::set_len(v, ln - 1u);
316308
val
317-
*/
318309
}
319310

320311
/*

0 commit comments

Comments
 (0)