Use BufWriter (instead of LineWriter) for FILEs other than stdout and stderr

BufWriter has more capacity (8k vs 1k) and doesn't flush the stream after '\n'.
That change helps to reduce the number of syscalls, especially when dealing with text files.

Since BufWriter has a different way of getting number of pending elements than LineWriter -
Pending trait was introduced to deal with that.
This commit is contained in:
Mateusz Tabaka
2021-01-14 17:30:46 +01:00
parent ccee7eae5f
commit 02f202ff83
6 changed files with 41 additions and 7 deletions
+3
View File
@@ -16,6 +16,7 @@ use crate::{
errno::{self, *},
fcntl::*,
limits,
stdio::flush_io_streams,
string::*,
time::constants::CLOCK_MONOTONIC,
unistd::{self, sysconf, _SC_PAGESIZE},
@@ -297,6 +298,8 @@ pub unsafe extern "C" fn exit(status: c_int) {
pthread_terminate();
flush_io_streams();
Sys::exit(status);
}