Commit 6d54cd4 1 parent 8b2600d commit 6d54cd4 Copy full SHA for 6d54cd4
File tree 6 files changed +10
-11
lines changed
6 files changed +10
-11
lines changed Original file line number Diff line number Diff line change @@ -289,7 +289,7 @@ mod lazy;
289
289
mod util;
290
290
mod stdio;
291
291
292
- const DEFAULT_BUF_SIZE : usize = 8 * 1024 ;
292
+ const DEFAULT_BUF_SIZE : usize = :: sys_common :: io :: DEFAULT_BUF_SIZE ;
293
293
294
294
// A few methods below (read_to_string, read_line) will append data into a
295
295
// `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 {
214
214
_ => Maybe :: Fake
215
215
} ;
216
216
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) ) )
226
218
}
227
219
}
228
220
Original file line number Diff line number Diff line change @@ -12,6 +12,8 @@ use io::ErrorKind;
12
12
use io:: Read ;
13
13
use slice:: from_raw_parts_mut;
14
14
15
+ pub const DEFAULT_BUF_SIZE : usize = 8 * 1024 ;
16
+
15
17
// Provides read_to_end functionality over an uninitialized buffer.
16
18
// This function is unsafe because it calls the underlying
17
19
// 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 {
67
67
}
68
68
69
69
pub 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 {
207
207
}
208
208
209
209
pub 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] = &[
66
66
"src/libstd/lib.rs" , // This could probably be done within the sys directory
67
67
"src/libstd/rtdeps.rs" , // Until rustbuild replaces make
68
68
"src/libstd/path.rs" ,
69
- "src/libstd/io/stdio.rs" ,
70
69
"src/libstd/num/f32.rs" ,
71
70
"src/libstd/num/f64.rs" ,
72
71
"src/libstd/sys/common/mod.rs" ,
You can’t perform that action at this time.
0 commit comments