std: Switch stdout/stderr to buffered by default
Similarly to #12422 which made stdin buffered by default, this commit makes the output streams also buffered by default. Now that buffered writers will flush their contents when they are dropped, I don't believe that there's no reason why the output shouldn't be buffered by default, which is what you want in 90% of cases. As with stdin, there are new stdout_raw() and stderr_raw() functions to get unbuffered streams to stdout/stderr.
This commit is contained in:
parent
1ee94a1336
commit
2cb83fdd7e
9 changed files with 41 additions and 21 deletions
|
|
@ -9,7 +9,7 @@
|
|||
// except according to those terms.
|
||||
|
||||
use std::cmp::min;
|
||||
use std::io::{stdout, BufferedWriter, IoResult};
|
||||
use std::io::{stdout, IoResult};
|
||||
use std::os;
|
||||
use std::vec::bytes::copy_memory;
|
||||
use std::vec;
|
||||
|
|
@ -183,7 +183,7 @@ fn main() {
|
|||
5
|
||||
};
|
||||
|
||||
let mut out = BufferedWriter::new(stdout());
|
||||
let mut out = stdout();
|
||||
|
||||
out.write_line(">ONE Homo sapiens alu").unwrap();
|
||||
{
|
||||
|
|
|
|||
|
|
@ -117,6 +117,6 @@ fn main() {
|
|||
let mut file = BufferedWriter::new(File::create(&Path::new("./shootout-fasta.data")));
|
||||
run(&mut file);
|
||||
} else {
|
||||
run(&mut BufferedWriter::new(io::stdout()));
|
||||
run(&mut io::stdout());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
// except according to those terms.
|
||||
|
||||
use std::io;
|
||||
use std::io::BufferedWriter;
|
||||
|
||||
struct DummyWriter;
|
||||
impl Writer for DummyWriter {
|
||||
|
|
@ -27,7 +26,7 @@ fn main() {
|
|||
(1000, ~DummyWriter as ~Writer)
|
||||
} else {
|
||||
(from_str(args[1]).unwrap(),
|
||||
~BufferedWriter::new(std::io::stdout()) as ~Writer)
|
||||
~std::io::stdout() as ~Writer)
|
||||
};
|
||||
let h = w;
|
||||
let mut byte_acc = 0u8;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue