diff options
| author | bors <bors@rust-lang.org> | 2024-09-25 04:57:12 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-09-25 04:57:12 +0000 |
| commit | 4c62024cd5dbafb64941bded422e4fbc2a100e73 (patch) | |
| tree | d53288325071e253910a6b5ffbdef798a43a08a1 /library/std/src/sys | |
| parent | 1b5aa96d6016bafe50e071b45d4d2e3c90fd766f (diff) | |
| parent | 458537ebc0e7d893103e03450f8830061bab1b2d (diff) | |
| download | rust-4c62024cd5dbafb64941bded422e4fbc2a100e73.tar.gz rust-4c62024cd5dbafb64941bded422e4fbc2a100e73.zip | |
Auto merge of #130803 - cuviper:file-buffered, r=joshtriplett
Add `File` constructors that return files wrapped with a buffer In addition to the light convenience, these are intended to raise visibility that buffering is something you should consider when opening a file, since unbuffered I/O is a common performance footgun to Rust newcomers. ACP: https://github.com/rust-lang/libs-team/issues/446 Tracking Issue: #130804
Diffstat (limited to 'library/std/src/sys')
| -rw-r--r-- | library/std/src/sys/pal/unix/thread.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/library/std/src/sys/pal/unix/thread.rs b/library/std/src/sys/pal/unix/thread.rs index 7fe9b6c3e52..ce5e8ea5866 100644 --- a/library/std/src/sys/pal/unix/thread.rs +++ b/library/std/src/sys/pal/unix/thread.rs @@ -517,7 +517,7 @@ mod cgroups { use crate::borrow::Cow; use crate::ffi::OsString; use crate::fs::{File, exists}; - use crate::io::{BufRead, BufReader, Read}; + use crate::io::{BufRead, Read}; use crate::os::unix::ffi::OsStringExt; use crate::path::{Path, PathBuf}; use crate::str::from_utf8; @@ -690,7 +690,7 @@ mod cgroups { /// If the cgroupfs is a bind mount then `group_path` is adjusted to skip /// over the already-included prefix fn find_mountpoint(group_path: &Path) -> Option<(Cow<'static, str>, &Path)> { - let mut reader = BufReader::new(File::open("/proc/self/mountinfo").ok()?); + let mut reader = File::open_buffered("/proc/self/mountinfo").ok()?; let mut line = String::with_capacity(256); loop { line.clear(); |
