native: remove some internal ~[].
This commit is contained in:
parent
8ec16e1e66
commit
32cf4a188c
@ -102,11 +102,11 @@ 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); }
|
||||
@ -114,7 +114,7 @@ fn helper(input: libc::c_int, messages: Receiver<Req>) {
|
||||
}
|
||||
|
||||
// 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<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;
|
||||
}
|
||||
@ -145,7 +145,7 @@ fn helper(input: libc::c_int, messages: Receiver<Req>) {
|
||||
// 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
|
||||
|
@ -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(),
|
||||
@ -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),
|
||||
@ -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) {
|
||||
@ -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);
|
||||
|
@ -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 {
|
||||
@ -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
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user