From 3ab18651775f125a6cfb07e184ea6c29482c4789 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dawid=20Ci=C4=99=C5=BCarkiewicz?= Date: Wed, 19 Mar 2014 09:35:33 -0700 Subject: [PATCH] Use raw stdin/stdio. Buffered one is expensive and serves no purpose. (cherry picked from commit ace707d5044026b1167b3326692c8c8f118e05e4) --- cat/cat.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cat/cat.rs b/cat/cat.rs index 815c08fbe..9c806d9b1 100644 --- a/cat/cat.rs +++ b/cat/cat.rs @@ -15,7 +15,8 @@ extern crate getopts; use std::os; -use std::io::{print, stdin, stdout, File}; +use std::io::{print, File}; +use std::io::stdio::{stdout_raw, stdin_raw}; fn main() { let args = os::args(); @@ -95,7 +96,7 @@ fn is_newline_char(byte: u8) -> bool { } pub fn exec(files: ~[~str], number: NumberingMode, show_nonprint: bool, show_ends: bool, show_tabs: bool, squeeze_blank: bool) { - let mut writer = stdout(); + let mut writer = stdout_raw(); if NumberNone != number || show_nonprint || show_ends || show_tabs || squeeze_blank { let mut counter: uint = 1; @@ -192,7 +193,7 @@ pub fn exec(files: ~[~str], number: NumberingMode, show_nonprint: bool, show_end fn open(path: ~str) -> Option<~Reader> { if "-" == path { - return Some(~stdin() as ~Reader); + return Some(~stdin_raw() as ~Reader); } match File::open(&std::path::Path::new(path.as_slice())) {