Skip to content

Commit d20b1a8

Browse files
committed
Set capacity of the string passed to push_item_name.
Other callsites already do this, but these two were missed. This avoids some allocations.
1 parent f2d863f commit d20b1a8

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

compiler/rustc_codegen_llvm/src/debuginfo/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ impl<'ll, 'tcx> DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
331331
llvm::LLVMRustDIBuilderCreateSubroutineType(DIB(self), fn_signature)
332332
};
333333

334-
let mut name = String::new();
334+
let mut name = String::with_capacity(64);
335335
type_names::push_item_name(tcx, def_id, false, &mut name);
336336

337337
// Find the enclosing function, in case this is a closure.

compiler/rustc_codegen_llvm/src/debuginfo/namespace.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub fn item_namespace<'ll>(cx: &CodegenCx<'ll, '_>, def_id: DefId) -> &'ll DISco
2828
.map(|parent| item_namespace(cx, DefId { krate: def_id.krate, index: parent }));
2929

3030
let namespace_name_string = {
31-
let mut output = String::new();
31+
let mut output = String::with_capacity(64);
3232
type_names::push_item_name(cx.tcx, def_id, false, &mut output);
3333
output
3434
};

0 commit comments

Comments
 (0)