From 34bd439378aea107c79b801e6e10502d81d1fd1b Mon Sep 17 00:00:00 2001 From: Justus Winter Date: Fri, 31 Jul 2020 17:43:17 +0200 Subject: openpgp: Improve comparing secret key material. - Do not explicitly shortcut the iteration by using fold instead of find. --- openpgp/src/crypto/mpi.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/openpgp/src/crypto/mpi.rs b/openpgp/src/crypto/mpi.rs index 6814e61f..d7e91d2c 100644 --- a/openpgp/src/crypto/mpi.rs +++ b/openpgp/src/crypto/mpi.rs @@ -673,11 +673,9 @@ impl PartialOrd for SecretKeyMaterial { a.cmp(b) }).collect::>(); - iter::once(&o1) - .chain(on.iter()) - .find(|&&x| x != Ordering::Equal) - .cloned() - .unwrap_or(Ordering::Equal) + iter::once(o1) + .chain(on.iter().cloned()) + .fold(Ordering::Equal, |acc, x| acc.then(x)) } (a, b) => { -- cgit v1.2.3