From 8bc9b672cb76a3e0e2ecadc39b344e653ecee214 Mon Sep 17 00:00:00 2001 From: Arcterus Date: Wed, 9 Jul 2014 19:51:51 -0700 Subject: [PATCH] wc: stop buffering stdin twice --- wc/wc.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/wc/wc.rs b/wc/wc.rs index 110369659..bba4d8ae3 100644 --- a/wc/wc.rs +++ b/wc/wc.rs @@ -15,7 +15,7 @@ extern crate getopts; extern crate libc; use std::str::from_utf8; -use std::io::{print, stdin, File, BufferedReader}; +use std::io::{print, stdin_raw, File, BufferedReader}; use StdResult = std::result::Result; use getopts::Matches; @@ -87,6 +87,7 @@ static TAB: u8 = '\t' as u8; static SYN: u8 = 0x16 as u8; static FF: u8 = 0x0C as u8; +#[inline(always)] fn is_word_seperator(byte: u8) -> bool { byte == SPACE || byte == TAB || byte == CR || byte == SYN || byte == FF } @@ -230,7 +231,7 @@ fn print_stats(filename: &str, line_count: uint, word_count: uint, char_count: u fn open(path: String) -> StdResult>, int> { if "-" == path.as_slice() { - let reader = box stdin() as Box; + let reader = box stdin_raw() as Box; return Ok(BufferedReader::new(reader)); }