Skip to content

Commit

Permalink
Preallocate a buffer in FmtPrinter
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark-Simulacrum committed Feb 21, 2022
1 parent efb99d7 commit 2ee6d55
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion compiler/rustc_middle/src/ty/print/pretty.rs
Expand Up @@ -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,
Expand Down

0 comments on commit 2ee6d55

Please sign in to comment.