diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2020-02-17 16:56:32 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2020-02-17 16:56:32 +0100 |
commit | 58ad7f331cb8c3d69c328e1b14604fac57bce5f7 (patch) | |
tree | 7b9dd02e7010e94e918196b106e837cfdc066a53 | |
parent | ca998b812390ff358797ac0d4d7fecb80f28c8a6 (diff) |
openpgp: Reduce use of Key4::set_secret.
-rw-r--r-- | openpgp/src/cert/mod.rs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/openpgp/src/cert/mod.rs b/openpgp/src/cert/mod.rs index 03dc4e46..0feebdec 100644 --- a/openpgp/src/cert/mod.rs +++ b/openpgp/src/cert/mod.rs @@ -1237,10 +1237,10 @@ impl Cert { // - One is corrupted // - There are two versions that are encrypted differently self.subkeys.sort_and_dedup(Key::public_cmp, - |ref mut a, ref mut b| { + |a, b| { // Recall: if a and b are equal, a will be dropped. if b.secret().is_none() && a.secret().is_some() { - b.set_secret(a.set_secret(None)); + std::mem::swap(a, b); } }); @@ -1319,8 +1319,10 @@ impl Cert { "Primary key mismatch".into()).into()); } - if self.primary.key().secret().is_none() && other.primary.key().secret().is_some() { - self.primary.key_mut().set_secret(other.primary.key_mut().set_secret(None)); + if self.primary.key().secret().is_none() + && other.primary.key().secret().is_some() + { + std::mem::swap(self.primary.key_mut(), other.primary.key_mut()); } self.primary.self_signatures.append( |