Skip to content

Commit a452111

Browse files
committed
native: remove some internal ~[].
1 parent 1f51301 commit a452111

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

Diff for: src/libnative/io/timer_other.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -102,19 +102,19 @@ fn helper(input: libc::c_int, messages: Receiver<Req>) {
102102
// active timers are those which are able to be selected upon (and it's a
103103
// sorted list, and dead timers are those which have expired, but ownership
104104
// hasn't yet been transferred back to the timer itself.
105-
let mut active: ~[~Inner] = ~[];
106-
let mut dead = ~[];
105+
let mut active: Vec<~Inner> = vec![];
106+
let mut dead = vec![];
107107

108108
// inserts a timer into an array of timers (sorted by firing time)
109-
fn insert(t: ~Inner, active: &mut ~[~Inner]) {
109+
fn insert(t: ~Inner, active: &mut Vec<~Inner>) {
110110
match active.iter().position(|tm| tm.target > t.target) {
111111
Some(pos) => { active.insert(pos, t); }
112112
None => { active.push(t); }
113113
}
114114
}
115115

116116
// signals the first requests in the queue, possible re-enqueueing it.
117-
fn signal(active: &mut ~[~Inner], dead: &mut ~[(uint, ~Inner)]) {
117+
fn signal(active: &mut Vec<~Inner>, dead: &mut Vec<(uint, ~Inner)>) {
118118
let mut timer = match active.shift() {
119119
Some(timer) => timer, None => return
120120
};
@@ -137,15 +137,15 @@ fn helper(input: libc::c_int, messages: Receiver<Req>) {
137137
let now = now();
138138
// If this request has already expired, then signal it and go
139139
// through another iteration
140-
if active[0].target <= now {
140+
if active.get(0).target <= now {
141141
signal(&mut active, &mut dead);
142142
continue;
143143
}
144144

145145
// The actual timeout listed in the requests array is an
146146
// absolute date, so here we translate the absolute time to a
147147
// relative time.
148-
let tm = active[0].target - now;
148+
let tm = active.get(0).target - now;
149149
timeout.tv_sec = (tm / 1000) as libc::time_t;
150150
timeout.tv_usec = ((tm % 1000) * 1000) as libc::suseconds_t;
151151
&timeout as *libc::timeval

Diff for: src/libnative/io/timer_timerfd.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ fn helper(input: libc::c_int, messages: Receiver<Req>) {
7676

7777
add(efd, input);
7878
let events: [imp::epoll_event, ..16] = unsafe { mem::init() };
79-
let mut list: ~[(libc::c_int, Sender<()>, bool)] = ~[];
79+
let mut list: Vec<(libc::c_int, Sender<()>, bool)> = vec![];
8080
'outer: loop {
8181
let n = match unsafe {
8282
imp::epoll_wait(efd, events.as_ptr(),
@@ -104,9 +104,9 @@ fn helper(input: libc::c_int, messages: Receiver<Req>) {
104104
// times?
105105
let _ = FileDesc::new(fd, false).inner_read(bits).unwrap();
106106
let (remove, i) = {
107-
match list.bsearch(|&(f, _, _)| f.cmp(&fd)) {
107+
match list.as_slice().bsearch(|&(f, _, _)| f.cmp(&fd)) {
108108
Some(i) => {
109-
let (_, ref c, oneshot) = list[i];
109+
let (_, ref c, oneshot) = *list.get(i);
110110
(!c.try_send(()) || oneshot, i)
111111
}
112112
None => fail!("fd not active: {}", fd),
@@ -128,9 +128,9 @@ fn helper(input: libc::c_int, messages: Receiver<Req>) {
128128

129129
// If we haven't previously seen the file descriptor, then
130130
// we need to add it to the epoll set.
131-
match list.bsearch(|&(f, _, _)| f.cmp(&fd)) {
131+
match list.as_slice().bsearch(|&(f, _, _)| f.cmp(&fd)) {
132132
Some(i) => {
133-
drop(mem::replace(&mut list[i], (fd, chan, one)));
133+
drop(mem::replace(list.get_mut(i), (fd, chan, one)));
134134
}
135135
None => {
136136
match list.iter().position(|&(f, _, _)| f >= fd) {
@@ -150,7 +150,7 @@ fn helper(input: libc::c_int, messages: Receiver<Req>) {
150150
}
151151

152152
Data(RemoveTimer(fd, chan)) => {
153-
match list.bsearch(|&(f, _, _)| f.cmp(&fd)) {
153+
match list.as_slice().bsearch(|&(f, _, _)| f.cmp(&fd)) {
154154
Some(i) => {
155155
drop(list.remove(i));
156156
del(efd, fd);

Diff for: src/libnative/io/timer_win32.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ pub enum Req {
4040
}
4141

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

4646
'outer: loop {
4747
let idx = unsafe {
@@ -78,7 +78,7 @@ fn helper(input: libc::HANDLE, messages: Receiver<Req>) {
7878
}
7979
} else {
8080
let remove = {
81-
match &chans[idx as uint - 1] {
81+
match chans.get(idx as uint - 1) {
8282
&(ref c, oneshot) => !c.try_send(()) || oneshot
8383
}
8484
};

0 commit comments

Comments
 (0)