Skip to content

Commit

Permalink
native: remove some internal ~[].
Browse files Browse the repository at this point in the history
  • Loading branch information
huonw authored and alexcrichton committed Apr 10, 2014
1 parent 8ec16e1 commit 32cf4a1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
12 changes: 6 additions & 6 deletions src/libnative/io/timer_other.rs
Expand Up @@ -102,19 +102,19 @@ fn helper(input: libc::c_int, messages: Receiver<Req>) {
// 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); }
}
}

// 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
};
Expand All @@ -137,15 +137,15 @@ fn helper(input: libc::c_int, messages: Receiver<Req>) {
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;
}

// 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
Expand Down
12 changes: 6 additions & 6 deletions src/libnative/io/timer_timerfd.rs
Expand Up @@ -76,7 +76,7 @@ fn helper(input: libc::c_int, messages: Receiver<Req>) {

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(),
Expand Down Expand Up @@ -104,9 +104,9 @@ fn helper(input: libc::c_int, messages: Receiver<Req>) {
// 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),
Expand All @@ -128,9 +128,9 @@ fn helper(input: libc::c_int, messages: Receiver<Req>) {

// 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) {
Expand All @@ -150,7 +150,7 @@ fn helper(input: libc::c_int, messages: Receiver<Req>) {
}

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);
Expand Down
6 changes: 3 additions & 3 deletions src/libnative/io/timer_win32.rs
Expand Up @@ -40,8 +40,8 @@ pub enum Req {
}

fn helper(input: libc::HANDLE, messages: Receiver<Req>) {
let mut objs = ~[input];
let mut chans = ~[];
let mut objs = vec![input];
let mut chans = vec![];

'outer: loop {
let idx = unsafe {
Expand Down Expand Up @@ -78,7 +78,7 @@ fn helper(input: libc::HANDLE, messages: Receiver<Req>) {
}
} else {
let remove = {
match &chans[idx as uint - 1] {
match chans.get(idx as uint - 1) {
&(ref c, oneshot) => !c.try_send(()) || oneshot
}
};
Expand Down

0 comments on commit 32cf4a1

Please sign in to comment.