diff options
| author | Mark Rousskov <mark.simulacrum@gmail.com> | 2022-02-19 14:49:35 -0500 |
|---|---|---|
| committer | Mark Rousskov <mark.simulacrum@gmail.com> | 2022-02-20 19:32:19 -0500 |
| commit | 2ee6d55c62e9b62a20b5a87a7665e9836b879120 (patch) | |
| tree | f43803d4ad3780841a4ee5e679b2d1f245a21af6 | |
| parent | efb99d780d282b50c29e429903398553665f4c06 (diff) | |
| download | rust-2ee6d55c62e9b62a20b5a87a7665e9836b879120.tar.gz rust-2ee6d55c62e9b62a20b5a87a7665e9836b879120.zip | |
Preallocate a buffer in FmtPrinter
| -rw-r--r-- | compiler/rustc_middle/src/ty/print/pretty.rs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index 0e94ac40ff7..80ba7232a4a 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -1583,7 +1583,9 @@ impl<'a, 'tcx> FmtPrinter<'a, 'tcx> { pub fn new(tcx: TyCtxt<'tcx>, ns: Namespace) -> Self { FmtPrinter(Box::new(FmtPrinterData { tcx, - fmt: String::new(), + // Estimated reasonable capacity to allocate upfront based on a few + // benchmarks. + fmt: String::with_capacity(64), empty_path: false, in_value: ns == Namespace::ValueNS, print_alloc_ids: false, |
