diff options
| author | Simon BD <simon@server> | 2012-10-22 18:33:41 -0500 |
|---|---|---|
| committer | Simon BD <simon@server> | 2012-10-22 18:33:41 -0500 |
| commit | cc0f2c6bb26ba38d3487a396fa8625e938af6820 (patch) | |
| tree | 6c2063df35144c5477b0adc9e49933d71224dc2a /src/rustdoc/markdown_writer.rs | |
| parent | 9aec7a3e85c5b07923eab05d3ebe9d031bf258f3 (diff) | |
| parent | 9ee5fff4f16cfc3390bd69abbb46b0a68521667c (diff) | |
| download | rust-cc0f2c6bb26ba38d3487a396fa8625e938af6820.tar.gz rust-cc0f2c6bb26ba38d3487a396fa8625e938af6820.zip | |
Merge remote-tracking branch 'original/incoming' into incoming
Diffstat (limited to 'src/rustdoc/markdown_writer.rs')
| -rw-r--r-- | src/rustdoc/markdown_writer.rs | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/src/rustdoc/markdown_writer.rs b/src/rustdoc/markdown_writer.rs index f505f9d0b99..1ed007def63 100644 --- a/src/rustdoc/markdown_writer.rs +++ b/src/rustdoc/markdown_writer.rs @@ -136,17 +136,20 @@ fn readclose(fd: libc::c_int) -> ~str { // Copied from run::program_output let file = os::fdopen(fd); let reader = io::FILE_reader(file, false); - let mut buf = ~""; - while !reader.eof() { - let bytes = reader.read_bytes(4096u); - buf += str::from_bytes(bytes); - } + let buf = io::with_bytes_writer(|writer| { + let mut bytes = [mut 0, ..4096]; + while !reader.eof() { + let nread = reader.read(bytes, bytes.len()); + writer.write(bytes.view(0, nread)); + } + }); os::fclose(file); - return buf; + str::from_bytes(buf) } fn generic_writer(+process: fn~(markdown: ~str)) -> Writer { - let ch = do task::spawn_listener |po: comm::Port<WriteInstr>| { + let ch = do task::spawn_listener + |move process, po: comm::Port<WriteInstr>| { let mut markdown = ~""; let mut keep_going = true; while keep_going { @@ -155,7 +158,7 @@ fn generic_writer(+process: fn~(markdown: ~str)) -> Writer { Done => keep_going = false } } - process(markdown); + process(move markdown); }; fn~(+instr: WriteInstr) { @@ -274,22 +277,22 @@ fn future_writer_factory( let writer_ch = comm::Chan(&writer_po); do task::spawn { let (writer, future) = future_writer(); - comm::send(writer_ch, writer); + comm::send(writer_ch, move writer); let s = future::get(&future); comm::send(markdown_ch, (page, s)); } comm::recv(writer_po) }; - (writer_factory, markdown_po) + (move writer_factory, markdown_po) } fn future_writer() -> (Writer, future::Future<~str>) { let (chan, port) = pipes::stream(); - let writer = fn~(+instr: WriteInstr) { + let writer = fn~(move chan, +instr: WriteInstr) { chan.send(copy instr); }; - let future = do future::from_fn { + let future = do future::from_fn |move port| { let mut res = ~""; loop { match port.recv() { @@ -299,5 +302,5 @@ fn future_writer() -> (Writer, future::Future<~str>) { } res }; - (writer, future) + (move writer, move future) } |
