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
This commit is contained in:
commit
4c62024cd5
33 changed files with 151 additions and 41 deletions
|
@ -1,5 +1,6 @@
|
|||
// tidy-alphabetical-start
|
||||
#![feature(array_windows)]
|
||||
#![feature(file_buffered)]
|
||||
#![feature(if_let_guard)]
|
||||
#![feature(let_chains)]
|
||||
#![warn(unreachable_pub)]
|
||||
|
|
|
@ -95,7 +95,7 @@
|
|||
use std::cmp;
|
||||
use std::collections::hash_map::Entry;
|
||||
use std::fs::{self, File};
|
||||
use std::io::{BufWriter, Write};
|
||||
use std::io::Write;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
|
||||
|
@ -1243,8 +1243,7 @@ fn dump_mono_items_stats<'tcx>(
|
|||
let ext = format.extension();
|
||||
let filename = format!("{crate_name}.mono_items.{ext}");
|
||||
let output_path = output_directory.join(&filename);
|
||||
let file = File::create(&output_path)?;
|
||||
let mut file = BufWriter::new(file);
|
||||
let mut file = File::create_buffered(&output_path)?;
|
||||
|
||||
// Gather instantiated mono items grouped by def_id
|
||||
let mut items_per_def_id: FxIndexMap<_, Vec<_>> = Default::default();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue