mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
Use Buffered input/output where it makes sense.
(cherry picked from commit c084bb1568d62d0e3e17151c8a4e859a95805a07)
This commit is contained in:
parent
3ab1865177
commit
a42bdea8ac
1 changed files with 3 additions and 1 deletions
|
@ -17,6 +17,7 @@ extern crate getopts;
|
||||||
use std::os;
|
use std::os;
|
||||||
use std::io::{print, File};
|
use std::io::{print, File};
|
||||||
use std::io::stdio::{stdout_raw, stdin_raw};
|
use std::io::stdio::{stdout_raw, stdin_raw};
|
||||||
|
use std::io::{BufferedReader, BufferedWriter};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let args = os::args();
|
let args = os::args();
|
||||||
|
@ -96,7 +97,6 @@ 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) {
|
pub fn exec(files: ~[~str], number: NumberingMode, show_nonprint: bool, show_ends: bool, show_tabs: bool, squeeze_blank: bool) {
|
||||||
let mut writer = stdout_raw();
|
|
||||||
|
|
||||||
if NumberNone != number || show_nonprint || show_ends || show_tabs || squeeze_blank {
|
if NumberNone != number || show_nonprint || show_ends || show_tabs || squeeze_blank {
|
||||||
let mut counter: uint = 1;
|
let mut counter: uint = 1;
|
||||||
|
@ -108,6 +108,7 @@ pub fn exec(files: ~[~str], number: NumberingMode, show_nonprint: bool, show_end
|
||||||
None => { continue }
|
None => { continue }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let mut writer = BufferedWriter::with_capacity(1024 * 8, stdout_raw());
|
||||||
let mut at_line_start = true;
|
let mut at_line_start = true;
|
||||||
let mut buf = [0, .. 2];
|
let mut buf = [0, .. 2];
|
||||||
loop {
|
loop {
|
||||||
|
@ -170,6 +171,7 @@ pub fn exec(files: ~[~str], number: NumberingMode, show_nonprint: bool, show_end
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut buf = [0, .. 100000];
|
let mut buf = [0, .. 100000];
|
||||||
|
let mut writer = stdout_raw();
|
||||||
// passthru mode
|
// passthru mode
|
||||||
for path in files.iter() {
|
for path in files.iter() {
|
||||||
let mut reader = match open(path.to_owned()) {
|
let mut reader = match open(path.to_owned()) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue