Skip to content

Commit 2ee6d55

Browse files
committedFeb 21, 2022
Preallocate a buffer in FmtPrinter
·
1.89.01.61.0
1 parent efb99d7 commit 2ee6d55

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed
 

‎compiler/rustc_middle/src/ty/print/pretty.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1583,7 +1583,9 @@ impl<'a, 'tcx> FmtPrinter<'a, 'tcx> {
15831583
pub fn new(tcx: TyCtxt<'tcx>, ns: Namespace) -> Self {
15841584
FmtPrinter(Box::new(FmtPrinterData {
15851585
tcx,
1586-
fmt: String::new(),
1586+
// Estimated reasonable capacity to allocate upfront based on a few
1587+
// benchmarks.
1588+
fmt: String::with_capacity(64),
15871589
empty_path: false,
15881590
in_value: ns == Namespace::ValueNS,
15891591
print_alloc_ids: false,

0 commit comments

Comments
 (0)
Please sign in to comment.