diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2020-01-24 13:32:50 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2020-01-24 13:32:50 +0100 |
commit | e9fcf9181f21cf7d687131e5aa191beb68a75a8e (patch) | |
tree | a184409916f77746fc24ca7086d4706aaef6dbf5 /openpgp/src/crypto/aead.rs | |
parent | a3510fd98f5aabf26ce3d3c76b249090386279c4 (diff) |
openpgp: Optimize drop(Vec<u8>::drain(..n)) in debug mode.
- Similar to Vec<u8>::truncate(_), this operation is very slow in
debug mode due to the dropping of drained elements. Provide an
optimized version in debug mode.
Diffstat (limited to 'openpgp/src/crypto/aead.rs')
-rw-r--r-- | openpgp/src/crypto/aead.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/openpgp/src/crypto/aead.rs b/openpgp/src/crypto/aead.rs index 35fbd074..a297b999 100644 --- a/openpgp/src/crypto/aead.rs +++ b/openpgp/src/crypto/aead.rs @@ -223,7 +223,7 @@ impl<'a> Decryptor<'a> { if self.buffer.len() > 0 { let to_copy = cmp::min(self.buffer.len(), plaintext.len()); &plaintext[..to_copy].copy_from_slice(&self.buffer[..to_copy]); - self.buffer.drain(..to_copy); + crate::vec_drain_prefix(&mut self.buffer, to_copy); pos = to_copy; if pos == plaintext.len() { @@ -341,7 +341,7 @@ impl<'a> Decryptor<'a> { &plaintext[pos..pos + to_copy] .copy_from_slice(&self.buffer[..to_copy]); - self.buffer.drain(..to_copy); + crate::vec_drain_prefix(&mut self.buffer, to_copy); pos += to_copy; } else { pos += to_decrypt; |