Skip to content

Commit 2f2fb8e

Browse files
committed
seq: Buffer writes to stdout
Use a BufWriter to wrap stdout: reduces the numbers of system calls, improves performance drastically (2x in some cases).
1 parent 2e3da88 commit 2f2fb8e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/uu/seq/src/seq.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// file that was distributed with this source code.
55
// spell-checker:ignore (ToDO) bigdecimal extendedbigdecimal numberparse hexadecimalfloat
66
use std::ffi::OsString;
7-
use std::io::{stdout, ErrorKind, Write};
7+
use std::io::{stdout, BufWriter, ErrorKind, Write};
88

99
use clap::{Arg, ArgAction, Command};
1010
use num_traits::{ToPrimitive, Zero};
@@ -262,8 +262,8 @@ fn print_seq(
262262
padding: usize,
263263
format: Option<&Format<num_format::Float>>,
264264
) -> std::io::Result<()> {
265-
let stdout = stdout();
266-
let mut stdout = stdout.lock();
265+
let stdout = stdout().lock();
266+
let mut stdout = BufWriter::new(stdout);
267267
let (first, increment, last) = range;
268268
let mut value = first;
269269
let padding = if pad {

0 commit comments

Comments
 (0)