Skip to content

Commit 944522e

Browse files
committed
---
yaml --- r: 144559 b: refs/heads/try2 c: 440f1e2 h: refs/heads/master i: 144557: e6486c4 144555: 2d59cc7 144551: 69d0d27 144543: a0220e8 v: v3
1 parent d5dbfa6 commit 944522e

File tree

3 files changed

+12
-17
lines changed

3 files changed

+12
-17
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 54e7bdc48e97d369acd51d1c08988fd946ccafd2
8+
refs/heads/try2: 440f1e2dadaf7c56575b65aa13c30abf9d5cec26
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libstd/rt/args.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,11 @@ pub fn clone() -> Option<~[~str]> {
5555
mod imp {
5656
use libc;
5757
use option::{Option, Some, None};
58-
use iterator::{Iterator, range};
58+
use iterator::Iterator;
5959
use str;
6060
use unstable::finally::Finally;
6161
use util;
62+
use vec;
6263

6364
pub unsafe fn init(argc: int, argv: **u8) {
6465
let args = load_argc_and_argv(argc, argv);
@@ -111,11 +112,9 @@ mod imp {
111112

112113
// Copied from `os`.
113114
unsafe fn load_argc_and_argv(argc: int, argv: **u8) -> ~[~str] {
114-
let mut args = ~[];
115-
for i in range(0u, argc as uint) {
116-
args.push(str::raw::from_c_str(*(argv as **libc::c_char).offset(i as int)));
115+
do vec::from_fn(argc as uint) |i| {
116+
str::raw::from_c_str(*(argv as **libc::c_char).offset(i as int))
117117
}
118-
args
119118
}
120119

121120
#[cfg(stage0)]

branches/try2/src/libstd/rt/mod.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Several modules in `core` are clients of `rt`:
5959
use cell::Cell;
6060
use clone::Clone;
6161
use container::Container;
62-
use iterator::{Iterator, range};
62+
use iterator::Iterator;
6363
use option::{Option, None, Some};
6464
use ptr::RawPtr;
6565
use rt::local::Local;
@@ -71,7 +71,8 @@ use rt::work_queue::WorkQueue;
7171
use rt::uv::uvio::UvEventLoop;
7272
use unstable::atomics::{AtomicInt, SeqCst};
7373
use unstable::sync::UnsafeArc;
74-
use vec::{OwnedVector, MutableVector};
74+
use vec;
75+
use vec::{OwnedVector, MutableVector, ImmutableVector};
7576

7677
/// The global (exchange) heap.
7778
pub mod global_heap;
@@ -251,25 +252,21 @@ fn run_(main: ~fn(), use_main_sched: bool) -> int {
251252

252253
// Create a work queue for each scheduler, ntimes. Create an extra
253254
// for the main thread if that flag is set. We won't steal from it.
254-
let mut work_queues = ~[];
255-
for _ in range(0u, nscheds) {
256-
let work_queue: WorkQueue<~Task> = WorkQueue::new();
257-
work_queues.push(work_queue);
258-
}
255+
let work_queues: ~[WorkQueue<~Task>] = vec::from_fn(nscheds, |_| WorkQueue::new());
259256

260257
// The schedulers.
261258
let mut scheds = ~[];
262259
// Handles to the schedulers. When the main task ends these will be
263260
// sent the Shutdown message to terminate the schedulers.
264261
let mut handles = ~[];
265262

266-
for i in range(0u, nscheds) {
263+
for work_queue in work_queues.iter() {
267264
rtdebug!("inserting a regular scheduler");
268265

269266
// Every scheduler is driven by an I/O event loop.
270267
let loop_ = ~UvEventLoop::new();
271268
let mut sched = ~Scheduler::new(loop_,
272-
work_queues[i].clone(),
269+
work_queue.clone(),
273270
work_queues.clone(),
274271
sleepers.clone());
275272
let handle = sched.make_handle();
@@ -358,9 +355,8 @@ fn run_(main: ~fn(), use_main_sched: bool) -> int {
358355
}
359356

360357
// Run each remaining scheduler in a thread.
361-
while !scheds.is_empty() {
358+
for sched in scheds.move_rev_iter() {
362359
rtdebug!("creating regular schedulers");
363-
let sched = scheds.pop();
364360
let sched_cell = Cell::new(sched);
365361
let thread = do Thread::start {
366362
let mut sched = sched_cell.take();

0 commit comments

Comments
 (0)