diff --git a/src/libnative/io/timer_other.rs b/src/libnative/io/timer_other.rs index 13f1ea6319a46..569b4cbb258e0 100644 --- a/src/libnative/io/timer_other.rs +++ b/src/libnative/io/timer_other.rs @@ -102,11 +102,11 @@ fn helper(input: libc::c_int, messages: Receiver) { // active timers are those which are able to be selected upon (and it's a // sorted list, and dead timers are those which have expired, but ownership // hasn't yet been transferred back to the timer itself. - let mut active: ~[~Inner] = ~[]; - let mut dead = ~[]; + let mut active: Vec<~Inner> = vec![]; + let mut dead = vec![]; // inserts a timer into an array of timers (sorted by firing time) - fn insert(t: ~Inner, active: &mut ~[~Inner]) { + fn insert(t: ~Inner, active: &mut Vec<~Inner>) { match active.iter().position(|tm| tm.target > t.target) { Some(pos) => { active.insert(pos, t); } None => { active.push(t); } @@ -114,7 +114,7 @@ fn helper(input: libc::c_int, messages: Receiver) { } // signals the first requests in the queue, possible re-enqueueing it. - fn signal(active: &mut ~[~Inner], dead: &mut ~[(uint, ~Inner)]) { + fn signal(active: &mut Vec<~Inner>, dead: &mut Vec<(uint, ~Inner)>) { let mut timer = match active.shift() { Some(timer) => timer, None => return }; @@ -137,7 +137,7 @@ fn helper(input: libc::c_int, messages: Receiver) { let now = now(); // If this request has already expired, then signal it and go // through another iteration - if active[0].target <= now { + if active.get(0).target <= now { signal(&mut active, &mut dead); continue; } @@ -145,7 +145,7 @@ fn helper(input: libc::c_int, messages: Receiver) { // The actual timeout listed in the requests array is an // absolute date, so here we translate the absolute time to a // relative time. - let tm = active[0].target - now; + let tm = active.get(0).target - now; timeout.tv_sec = (tm / 1000) as libc::time_t; timeout.tv_usec = ((tm % 1000) * 1000) as libc::suseconds_t; &timeout as *libc::timeval diff --git a/src/libnative/io/timer_timerfd.rs b/src/libnative/io/timer_timerfd.rs index 25dbdc1e1a5cd..d37a39fc30e8d 100644 --- a/src/libnative/io/timer_timerfd.rs +++ b/src/libnative/io/timer_timerfd.rs @@ -76,7 +76,7 @@ fn helper(input: libc::c_int, messages: Receiver) { add(efd, input); let events: [imp::epoll_event, ..16] = unsafe { mem::init() }; - let mut list: ~[(libc::c_int, Sender<()>, bool)] = ~[]; + let mut list: Vec<(libc::c_int, Sender<()>, bool)> = vec![]; 'outer: loop { let n = match unsafe { imp::epoll_wait(efd, events.as_ptr(), @@ -104,9 +104,9 @@ fn helper(input: libc::c_int, messages: Receiver) { // times? let _ = FileDesc::new(fd, false).inner_read(bits).unwrap(); let (remove, i) = { - match list.bsearch(|&(f, _, _)| f.cmp(&fd)) { + match list.as_slice().bsearch(|&(f, _, _)| f.cmp(&fd)) { Some(i) => { - let (_, ref c, oneshot) = list[i]; + let (_, ref c, oneshot) = *list.get(i); (!c.try_send(()) || oneshot, i) } None => fail!("fd not active: {}", fd), @@ -128,9 +128,9 @@ fn helper(input: libc::c_int, messages: Receiver) { // If we haven't previously seen the file descriptor, then // we need to add it to the epoll set. - match list.bsearch(|&(f, _, _)| f.cmp(&fd)) { + match list.as_slice().bsearch(|&(f, _, _)| f.cmp(&fd)) { Some(i) => { - drop(mem::replace(&mut list[i], (fd, chan, one))); + drop(mem::replace(list.get_mut(i), (fd, chan, one))); } None => { match list.iter().position(|&(f, _, _)| f >= fd) { @@ -150,7 +150,7 @@ fn helper(input: libc::c_int, messages: Receiver) { } Data(RemoveTimer(fd, chan)) => { - match list.bsearch(|&(f, _, _)| f.cmp(&fd)) { + match list.as_slice().bsearch(|&(f, _, _)| f.cmp(&fd)) { Some(i) => { drop(list.remove(i)); del(efd, fd); diff --git a/src/libnative/io/timer_win32.rs b/src/libnative/io/timer_win32.rs index 278a5a73a36bd..8b7592783da04 100644 --- a/src/libnative/io/timer_win32.rs +++ b/src/libnative/io/timer_win32.rs @@ -40,8 +40,8 @@ pub enum Req { } fn helper(input: libc::HANDLE, messages: Receiver) { - let mut objs = ~[input]; - let mut chans = ~[]; + let mut objs = vec![input]; + let mut chans = vec![]; 'outer: loop { let idx = unsafe { @@ -78,7 +78,7 @@ fn helper(input: libc::HANDLE, messages: Receiver) { } } else { let remove = { - match &chans[idx as uint - 1] { + match chans.get(idx as uint - 1) { &(ref c, oneshot) => !c.try_send(()) || oneshot } };