From 04880a89ed41f572203a1cd0beac24de8ea30646 Mon Sep 17 00:00:00 2001 From: Marcin S Date: Mon, 4 Sep 2023 19:19:18 +0200 Subject: [PATCH 1/4] Remove redundant calls to `borrow()` --- substrate/client/api/src/lib.rs | 4 +--- substrate/frame/support/src/storage/generator/map.rs | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/substrate/client/api/src/lib.rs b/substrate/client/api/src/lib.rs index faadf3663a59d..307fa2f9d61e6 100644 --- a/substrate/client/api/src/lib.rs +++ b/substrate/client/api/src/lib.rs @@ -69,10 +69,8 @@ pub mod utils { return Ok(false) } - let current = current.as_ref().map(|(c, p)| (c.borrow(), p.borrow())); - let mut hash = hash; - if let Some((current_hash, current_parent_hash)) = current { + if let Some((current_hash, current_parent_hash)) = current.as_ref() { if base == current_hash { return Ok(false) } diff --git a/substrate/frame/support/src/storage/generator/map.rs b/substrate/frame/support/src/storage/generator/map.rs index 90fac4b41c759..dcddde7192a5b 100644 --- a/substrate/frame/support/src/storage/generator/map.rs +++ b/substrate/frame/support/src/storage/generator/map.rs @@ -297,7 +297,7 @@ impl> storage::StorageMap let ret = f(&mut val); if ret.is_ok() { match G::from_query_to_optional_value(val) { - Some(ref val) => unhashed::put(final_key.as_ref(), &val.borrow()), + Some(ref val) => unhashed::put(final_key.as_ref(), &val), None => unhashed::kill(final_key.as_ref()), } } @@ -314,7 +314,7 @@ impl> storage::StorageMap let ret = f(&mut val); if ret.is_ok() { match val { - Some(ref val) => unhashed::put(final_key.as_ref(), &val.borrow()), + Some(ref val) => unhashed::put(final_key.as_ref(), &val), None => unhashed::kill(final_key.as_ref()), } } From a0b841a582251c99f6aac74d95fd8ef1f601c254 Mon Sep 17 00:00:00 2001 From: Marcin S Date: Tue, 5 Sep 2023 09:38:07 +0200 Subject: [PATCH 2/4] Update substrate/client/api/src/lib.rs Co-authored-by: Keith Yeung --- substrate/client/api/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/substrate/client/api/src/lib.rs b/substrate/client/api/src/lib.rs index 307fa2f9d61e6..dfc8a82888470 100644 --- a/substrate/client/api/src/lib.rs +++ b/substrate/client/api/src/lib.rs @@ -70,7 +70,7 @@ pub mod utils { } let mut hash = hash; - if let Some((current_hash, current_parent_hash)) = current.as_ref() { + if let Some((current_hash, current_parent_hash)) = ¤t { if base == current_hash { return Ok(false) } From ccdd73e2db51b9f3c6970f94cb5a36f8d46147c6 Mon Sep 17 00:00:00 2001 From: Marcin S Date: Tue, 5 Sep 2023 09:48:03 +0200 Subject: [PATCH 3/4] Remove unused imports --- substrate/client/api/src/lib.rs | 1 - substrate/frame/support/src/storage/generator/map.rs | 1 - 2 files changed, 2 deletions(-) diff --git a/substrate/client/api/src/lib.rs b/substrate/client/api/src/lib.rs index 307fa2f9d61e6..82f35ed4aff4c 100644 --- a/substrate/client/api/src/lib.rs +++ b/substrate/client/api/src/lib.rs @@ -49,7 +49,6 @@ pub trait UsageProvider { pub mod utils { use sp_blockchain::{Error, HeaderBackend, HeaderMetadata}; use sp_runtime::traits::Block as BlockT; - use std::borrow::Borrow; /// Returns a function for checking block ancestry, the returned function will /// return `true` if the given hash (second parameter) is a descendent of the diff --git a/substrate/frame/support/src/storage/generator/map.rs b/substrate/frame/support/src/storage/generator/map.rs index dcddde7192a5b..1d2511e324dc6 100644 --- a/substrate/frame/support/src/storage/generator/map.rs +++ b/substrate/frame/support/src/storage/generator/map.rs @@ -21,7 +21,6 @@ use crate::{ Never, }; use codec::{Decode, Encode, EncodeLike, FullCodec, FullEncode}; -use sp_std::borrow::Borrow; #[cfg(not(feature = "std"))] use sp_std::prelude::*; From 64b632a535f98f391c5d22361b691902dcad6762 Mon Sep 17 00:00:00 2001 From: Marcin S Date: Tue, 5 Sep 2023 10:58:51 +0200 Subject: [PATCH 4/4] Remove redundant `deref()` --- substrate/frame/message-queue/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/substrate/frame/message-queue/src/lib.rs b/substrate/frame/message-queue/src/lib.rs index 9ded84bb035c5..7c38dec4b0805 100644 --- a/substrate/frame/message-queue/src/lib.rs +++ b/substrate/frame/message-queue/src/lib.rs @@ -1092,7 +1092,7 @@ impl Pallet { origin.clone(), page_index, page.first_index, - payload.deref(), + payload, weight, overweight_limit, ) { @@ -1242,7 +1242,7 @@ impl Pallet { if let Some((_, processed, message)) = page.peek_index(i.try_into().expect("std-only code")) { - let msg = String::from_utf8_lossy(message.deref()); + let msg = String::from_utf8_lossy(message); if processed { page_info.push('*'); }