Skip to content

Commit

Permalink
Remove redundant calls to borrow() (#1393)
Browse files Browse the repository at this point in the history
Co-authored-by: Keith Yeung <kungfukeith11@gmail.com>
Co-authored-by: Francisco Aguirre <franciscoaguirreperez@gmail.com>
  • Loading branch information
3 people authored Sep 5, 2023
1 parent 1219444 commit ec8949f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
5 changes: 1 addition & 4 deletions substrate/client/api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ pub trait UsageProvider<Block: sp_runtime::traits::Block> {
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
Expand All @@ -69,10 +68,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 {
if base == current_hash {
return Ok(false)
}
Expand Down
4 changes: 2 additions & 2 deletions substrate/frame/message-queue/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1092,7 +1092,7 @@ impl<T: Config> Pallet<T> {
origin.clone(),
page_index,
page.first_index,
payload.deref(),
payload,
weight,
overweight_limit,
) {
Expand Down Expand Up @@ -1242,7 +1242,7 @@ impl<T: Config> Pallet<T> {
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('*');
}
Expand Down
5 changes: 2 additions & 3 deletions substrate/frame/support/src/storage/generator/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;

Expand Down Expand Up @@ -297,7 +296,7 @@ impl<K: FullEncode, V: FullCodec, G: StorageMap<K, V>> storage::StorageMap<K, V>
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()),
}
}
Expand All @@ -314,7 +313,7 @@ impl<K: FullEncode, V: FullCodec, G: StorageMap<K, V>> storage::StorageMap<K, V>
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()),
}
}
Expand Down

0 comments on commit ec8949f

Please sign in to comment.