diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2020-01-08 12:00:44 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2020-01-08 12:03:40 +0100 |
commit | 245fa8ddb2d3ac2fa03cd67434c0f61349c64ce2 (patch) | |
tree | 0ed62a4a829cabe0f925a255a48f9311d9b46c59 | |
parent | 5b0b546ce73cc3a2bfed085726c43635d5519924 (diff) |
openpgp: Improve PartialEq for OnePassSig3.
- Previously, we compared the serialized forms. This, however,
involves making heap allocations. For me, that breaks the
expectation that equality should be free of side-effects, and
fast. Compare the fields instead.
-rw-r--r-- | openpgp/src/packet/one_pass_sig.rs | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/openpgp/src/packet/one_pass_sig.rs b/openpgp/src/packet/one_pass_sig.rs index 68f69f77..debb2460 100644 --- a/openpgp/src/packet/one_pass_sig.rs +++ b/openpgp/src/packet/one_pass_sig.rs @@ -17,7 +17,6 @@ use crate::KeyID; use crate::HashAlgorithm; use crate::PublicKeyAlgorithm; use crate::SignatureType; -use crate::serialize::SerializeInto; /// Holds a one-pass signature packet. /// @@ -55,14 +54,11 @@ impl fmt::Debug for OnePassSig3 { impl PartialEq for OnePassSig3 { fn eq(&self, other: &OnePassSig3) -> bool { - // Comparing the relevant fields is error prone in case we add - // a field at some point. Instead, we compare the serialized - // versions. - if let (Ok(a), Ok(b)) = (self.to_vec(), other.to_vec()) { - a == b - } else { - false - } + self.typ == other.typ + && self.hash_algo == other.hash_algo + && self.pk_algo == other.pk_algo + && self.issuer == other.issuer + && self.last == other.last } } |