Skip to content

Commit c896271

Browse files
authored
write: reserve capacity for abbreviation Vec (#831)
Improves performance.
1 parent 8679a04 commit c896271

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/write/unit.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -615,9 +615,10 @@ impl DebuggingInformationEntry {
615615

616616
/// Return the type abbreviation for this DIE.
617617
fn abbreviation(&self, encoding: Encoding) -> Result<Abbreviation> {
618-
let mut attrs = Vec::new();
618+
let sibling = self.sibling && !self.children.is_empty();
619+
let mut attrs = Vec::with_capacity(usize::from(sibling) + self.attrs.len());
619620

620-
if self.sibling && !self.children.is_empty() {
621+
if sibling {
621622
let form = match encoding.format {
622623
Format::Dwarf32 => constants::DW_FORM_ref4,
623624
Format::Dwarf64 => constants::DW_FORM_ref8,

0 commit comments

Comments
 (0)