File tree Expand file tree Collapse file tree 6 files changed +10
-11
lines changed
Expand file tree Collapse file tree 6 files changed +10
-11
lines changed Original file line number Diff line number Diff line change @@ -289,7 +289,7 @@ mod lazy;
289289mod util;
290290mod stdio;
291291
292- const DEFAULT_BUF_SIZE : usize = 8 * 1024 ;
292+ const DEFAULT_BUF_SIZE : usize = :: sys_common :: io :: DEFAULT_BUF_SIZE ;
293293
294294// A few methods below (read_to_string, read_line) will append data into a
295295// `String` buffer, but we need to be pretty careful when doing this. The
Original file line number Diff line number Diff line change @@ -214,15 +214,7 @@ pub fn stdin() -> Stdin {
214214 _ => Maybe :: Fake
215215 } ;
216216
217- // The default buffer capacity is 64k, but apparently windows
218- // doesn't like 64k reads on stdin. See #13304 for details, but the
219- // idea is that on windows we use a slightly smaller buffer that's
220- // been seen to be acceptable.
221- Arc :: new ( Mutex :: new ( if cfg ! ( windows) {
222- BufReader :: with_capacity ( 8 * 1024 , stdin)
223- } else {
224- BufReader :: new ( stdin)
225- } ) )
217+ Arc :: new ( Mutex :: new ( BufReader :: with_capacity ( stdio:: STDIN_BUF_SIZE , stdin) ) )
226218 }
227219}
228220
Original file line number Diff line number Diff line change @@ -12,6 +12,8 @@ use io::ErrorKind;
1212use io:: Read ;
1313use slice:: from_raw_parts_mut;
1414
15+ pub const DEFAULT_BUF_SIZE : usize = 8 * 1024 ;
16+
1517// Provides read_to_end functionality over an uninitialized buffer.
1618// This function is unsafe because it calls the underlying
1719// read function with a slice into uninitialized memory. The default
Original file line number Diff line number Diff line change @@ -67,3 +67,4 @@ impl io::Write for Stderr {
6767}
6868
6969pub const EBADF_ERR : i32 = :: libc:: EBADF as i32 ;
70+ pub const STDIN_BUF_SIZE : usize = :: sys_common:: io:: DEFAULT_BUF_SIZE ;
Original file line number Diff line number Diff line change @@ -207,3 +207,8 @@ fn invalid_encoding() -> io::Error {
207207}
208208
209209pub const EBADF_ERR : i32 = :: sys:: c:: ERROR_INVALID_HANDLE as i32 ;
210+ // The default buffer capacity is 64k, but apparently windows
211+ // doesn't like 64k reads on stdin. See #13304 for details, but the
212+ // idea is that on windows we use a slightly smaller buffer that's
213+ // been seen to be acceptable.
214+ pub const STDIN_BUF_SIZE : usize = 8 * 1024 ;
Original file line number Diff line number Diff line change @@ -66,7 +66,6 @@ const EXCEPTION_PATHS: &'static [&'static str] = &[
6666 "src/libstd/lib.rs" , // This could probably be done within the sys directory
6767 "src/libstd/rtdeps.rs" , // Until rustbuild replaces make
6868 "src/libstd/path.rs" ,
69- "src/libstd/io/stdio.rs" ,
7069 "src/libstd/num/f32.rs" ,
7170 "src/libstd/num/f64.rs" ,
7271 "src/libstd/sys/common/mod.rs" ,
You can’t perform that action at this time.
0 commit comments