diff options
author | Neal H. Walfield <neal@pep.foundation> | 2019-10-30 13:12:19 +0100 |
---|---|---|
committer | Neal H. Walfield <neal@pep.foundation> | 2019-10-30 13:12:19 +0100 |
commit | 4a7eb553c489f9709928e64f580b5888885d88c3 (patch) | |
tree | 2c23e58357b8a6c97913f8043d7d264f59c62525 /openpgp/src | |
parent | de61cc9cb03856b08370a4965eec5b7ffa139b34 (diff) |
openpgp: Avoid unnecessary allocations.
- It's enough to clear the vector and reuse the existing memory.
Diffstat (limited to 'openpgp/src')
-rw-r--r-- | openpgp/src/armor.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/openpgp/src/armor.rs b/openpgp/src/armor.rs index 925d04a5..85a0a967 100644 --- a/openpgp/src/armor.rs +++ b/openpgp/src/armor.rs @@ -610,7 +610,7 @@ impl<'a> Reader<'a> { if lines > 0 { // Find the start of the next line. self.source.drop_through(&[b'\n'], true)?; - prefix = Vec::new(); + prefix.clear(); } lines += 1; @@ -626,7 +626,7 @@ impl<'a> Reader<'a> { let c = self.source.data(1)?[0]; if c == b'\n' { // We found a newline while walking whitespace, reset prefix - prefix = Vec::new(); + prefix.clear(); } else { prefix.push(self.source.data_hard(1)?[0]); } @@ -715,7 +715,7 @@ impl<'a> Reader<'a> { // was purely whitespace. Any non-whitespace remains an error // while searching for the armor header if it's not repeated. if prefix.iter().all(|b| (*b as char).is_ascii_whitespace()) { - prefix = Vec::new(); + prefix.clear(); } else { // Nope, we have actually failed to read this properly return Err( |