Skip to content

Commit

Permalink
Set capacity of the string passed to push_item_name.
Browse files Browse the repository at this point in the history
Other callsites already do this, but these two were missed. This avoids
some allocations.
  • Loading branch information
nnethercote committed Jun 29, 2023
1 parent f2d863f commit d20b1a8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/src/debuginfo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ impl<'ll, 'tcx> DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
llvm::LLVMRustDIBuilderCreateSubroutineType(DIB(self), fn_signature)
};

let mut name = String::new();
let mut name = String::with_capacity(64);
type_names::push_item_name(tcx, def_id, false, &mut name);

// Find the enclosing function, in case this is a closure.
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/src/debuginfo/namespace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub fn item_namespace<'ll>(cx: &CodegenCx<'ll, '_>, def_id: DefId) -> &'ll DISco
.map(|parent| item_namespace(cx, DefId { krate: def_id.krate, index: parent }));

let namespace_name_string = {
let mut output = String::new();
let mut output = String::with_capacity(64);
type_names::push_item_name(cx.tcx, def_id, false, &mut output);
output
};
Expand Down

0 comments on commit d20b1a8

Please sign in to comment.