Improving PSBT merge with dedicated 1.29 rustc borrow scope

This commit is contained in:
Dr Maxim Orlovsky 2020-12-07 16:41:57 +01:00
parent df8635c5fe
commit 0235abfac2
No known key found for this signature in database
GPG Key ID: FFC0250947E5C6F7
1 changed files with 5 additions and 4 deletions

View File

@ -173,12 +173,13 @@ impl Map for Global {
// 3) choose longest derivation; if equal
// 4) choose largest fingerprint; if equal
// 5) do nothing
// Clone is required for Rust 1.29 borrow checker
let (fingerprint2, derivation2) = entry.get().clone();
let (fingerprint2, len2, normal_len2) = {
// weird scope needed for rustc 1.29 borrow checker
let (fp, deriv) = entry.get().clone();
(fp, deriv.len(), deriv.into_iter().rposition(ChildNumber::is_normal))
};
let len1 = derivation1.len();
let len2 = derivation2.len();
let normal_len1 = derivation1.into_iter().rposition(ChildNumber::is_normal);
let normal_len2 = derivation2.into_iter().rposition(ChildNumber::is_normal);
match (normal_len1.cmp(&normal_len2), len1.cmp(&len2), fingerprint1.cmp(&fingerprint2)) {
(Ordering::Equal, Ordering::Equal, Ordering::Equal) => {},
(Ordering::Equal, _, Ordering::Equal) => {