Removes redundant mut
in ethcore
This commit is contained in:
parent
b0c15497e1
commit
3df67b376b
@ -64,7 +64,7 @@ impl AddressBook {
|
||||
/// Sets new name for given address.
|
||||
pub fn set_name(&mut self, a: Address, name: String) {
|
||||
{
|
||||
let mut x = self.cache.entry(a)
|
||||
let x = self.cache.entry(a)
|
||||
.or_insert_with(|| AccountMeta {name: Default::default(), meta: "{}".to_owned(), uuid: None});
|
||||
x.name = name;
|
||||
}
|
||||
@ -74,7 +74,7 @@ impl AddressBook {
|
||||
/// Sets new meta for given address.
|
||||
pub fn set_meta(&mut self, a: Address, meta: String) {
|
||||
{
|
||||
let mut x = self.cache.entry(a)
|
||||
let x = self.cache.entry(a)
|
||||
.or_insert_with(|| AccountMeta {name: "Anonymous".to_owned(), meta: Default::default(), uuid: None});
|
||||
x.meta = meta;
|
||||
}
|
||||
@ -253,7 +253,7 @@ impl DappsSettingsStore {
|
||||
/// Marks recent dapp as used
|
||||
pub fn mark_dapp_used(&mut self, dapp: DappId) {
|
||||
{
|
||||
let mut entry = self.history.entry(dapp).or_insert_with(|| Default::default());
|
||||
let entry = self.history.entry(dapp).or_insert_with(|| Default::default());
|
||||
entry.last_accessed = self.time.get();
|
||||
}
|
||||
// Clear extraneous entries
|
||||
@ -280,7 +280,7 @@ impl DappsSettingsStore {
|
||||
/// Sets accounts for specific dapp.
|
||||
pub fn set_accounts(&mut self, id: DappId, accounts: Option<Vec<Address>>) {
|
||||
{
|
||||
let mut settings = self.settings.entry(id).or_insert_with(DappsSettings::default);
|
||||
let settings = self.settings.entry(id).or_insert_with(DappsSettings::default);
|
||||
settings.accounts = accounts;
|
||||
}
|
||||
self.settings.save(JsonSettings::write);
|
||||
@ -289,7 +289,7 @@ impl DappsSettingsStore {
|
||||
/// Sets a default account for specific dapp.
|
||||
pub fn set_default(&mut self, id: DappId, default: Address) {
|
||||
{
|
||||
let mut settings = self.settings.entry(id).or_insert_with(DappsSettings::default);
|
||||
let settings = self.settings.entry(id).or_insert_with(DappsSettings::default);
|
||||
settings.default = Some(default);
|
||||
}
|
||||
self.settings.save(JsonSettings::write);
|
||||
|
@ -421,7 +421,7 @@ pub mod common {
|
||||
.and_then(|_| fields.state.commit());
|
||||
|
||||
let block_author = fields.header.author().clone();
|
||||
fields.traces.as_mut().map(move |mut traces| {
|
||||
fields.traces.as_mut().map(move |traces| {
|
||||
let mut tracer = ExecutiveTracer::default();
|
||||
tracer.trace_reward(block_author, reward, RewardType::Block);
|
||||
traces.push(tracer.drain())
|
||||
|
@ -433,7 +433,7 @@ impl<'a, B: 'a + StateBackend> Executive<'a, B> {
|
||||
// trace only top level calls to builtins to avoid DDoS attacks
|
||||
if self.depth == 0 {
|
||||
let mut trace_output = tracer.prepare_trace_output();
|
||||
if let Some(mut out) = trace_output.as_mut() {
|
||||
if let Some(out) = trace_output.as_mut() {
|
||||
*out = output.to_owned();
|
||||
}
|
||||
|
||||
|
@ -149,7 +149,7 @@ impl BanningTransactionQueue {
|
||||
/// queue.
|
||||
fn ban_sender(&mut self, address: Address) -> bool {
|
||||
let count = {
|
||||
let mut count = self.senders_bans.entry(address).or_insert_with(|| 0);
|
||||
let count = self.senders_bans.entry(address).or_insert_with(|| 0);
|
||||
*count = count.saturating_add(1);
|
||||
*count
|
||||
};
|
||||
@ -169,7 +169,7 @@ impl BanningTransactionQueue {
|
||||
/// Returns true if bans threshold has been reached.
|
||||
fn ban_recipient(&mut self, address: Address) -> bool {
|
||||
let count = {
|
||||
let mut count = self.recipients_bans.entry(address).or_insert_with(|| 0);
|
||||
let count = self.recipients_bans.entry(address).or_insert_with(|| 0);
|
||||
*count = count.saturating_add(1);
|
||||
*count
|
||||
};
|
||||
@ -185,7 +185,7 @@ impl BanningTransactionQueue {
|
||||
/// If bans threshold is reached all subsequent transactions to contracts with this codehash will be rejected.
|
||||
/// Returns true if bans threshold has been reached.
|
||||
fn ban_codehash(&mut self, code_hash: H256) -> bool {
|
||||
let mut count = self.codes_bans.entry(code_hash).or_insert_with(|| 0);
|
||||
let count = self.codes_bans.entry(code_hash).or_insert_with(|| 0);
|
||||
*count = count.saturating_add(1);
|
||||
|
||||
match self.ban_threshold {
|
||||
|
@ -341,7 +341,7 @@ impl GasPriceQueue {
|
||||
/// Remove an item from a BTreeMap/HashSet "multimap".
|
||||
/// Returns true if the item was removed successfully.
|
||||
pub fn remove(&mut self, gas_price: &U256, hash: &H256) -> bool {
|
||||
if let Some(mut hashes) = self.backing.get_mut(gas_price) {
|
||||
if let Some(hashes) = self.backing.get_mut(gas_price) {
|
||||
let only_one_left = hashes.len() == 1;
|
||||
if !only_one_left {
|
||||
// Operation may be ok: only if hash is in gas-price's Set.
|
||||
@ -1225,7 +1225,7 @@ impl TransactionQueue {
|
||||
if by_nonce.is_none() {
|
||||
return;
|
||||
}
|
||||
let mut by_nonce = by_nonce.expect("None is tested in early-exit condition above; qed");
|
||||
let by_nonce = by_nonce.expect("None is tested in early-exit condition above; qed");
|
||||
while let Some(order) = by_nonce.remove(¤t_nonce) {
|
||||
// remove also from priority and gas_price
|
||||
self.future.by_priority.remove(&order);
|
||||
|
@ -962,7 +962,7 @@ impl<B: Backend> State<B> {
|
||||
|
||||
// at this point the entry is guaranteed to be in the cache.
|
||||
Ok(RefMut::map(self.cache.borrow_mut(), |c| {
|
||||
let mut entry = c.get_mut(a).expect("entry known to exist in the cache; qed");
|
||||
let entry = c.get_mut(a).expect("entry known to exist in the cache; qed");
|
||||
|
||||
match &mut entry.account {
|
||||
&mut Some(ref mut acc) => not_default(acc),
|
||||
|
@ -211,7 +211,7 @@ impl StateDB {
|
||||
pub fn sync_cache(&mut self, enacted: &[H256], retracted: &[H256], is_best: bool) {
|
||||
trace!("sync_cache id = (#{:?}, {:?}), parent={:?}, best={}", self.commit_number, self.commit_hash, self.parent_hash, is_best);
|
||||
let mut cache = self.account_cache.lock();
|
||||
let mut cache = &mut *cache;
|
||||
let cache = &mut *cache;
|
||||
|
||||
// Purge changes from re-enacted and retracted blocks.
|
||||
// Filter out commiting block if any.
|
||||
|
@ -522,7 +522,7 @@ impl<K: Kind> VerificationQueue<K> {
|
||||
return;
|
||||
}
|
||||
let mut verified_lock = self.verification.verified.lock();
|
||||
let mut verified = &mut *verified_lock;
|
||||
let verified = &mut *verified_lock;
|
||||
let mut bad = self.verification.bad.lock();
|
||||
let mut processing = self.processing.write();
|
||||
bad.reserve(hashes.len());
|
||||
|
@ -35,7 +35,7 @@ impl KeyDirectory for MemoryDirectory {
|
||||
|
||||
fn update(&self, account: SafeAccount) -> Result<SafeAccount, Error> {
|
||||
let mut lock = self.accounts.write();
|
||||
let mut accounts = lock.entry(account.address.clone()).or_insert_with(Vec::new);
|
||||
let accounts = lock.entry(account.address.clone()).or_insert_with(Vec::new);
|
||||
// If the filename is the same we just need to replace the entry
|
||||
accounts.retain(|acc| acc.filename != account.filename);
|
||||
accounts.push(account.clone());
|
||||
@ -44,14 +44,14 @@ impl KeyDirectory for MemoryDirectory {
|
||||
|
||||
fn insert(&self, account: SafeAccount) -> Result<SafeAccount, Error> {
|
||||
let mut lock = self.accounts.write();
|
||||
let mut accounts = lock.entry(account.address.clone()).or_insert_with(Vec::new);
|
||||
let accounts = lock.entry(account.address.clone()).or_insert_with(Vec::new);
|
||||
accounts.push(account.clone());
|
||||
Ok(account)
|
||||
}
|
||||
|
||||
fn remove(&self, account: &SafeAccount) -> Result<(), Error> {
|
||||
let mut accounts = self.accounts.write();
|
||||
let is_empty = if let Some(mut accounts) = accounts.get_mut(&account.address) {
|
||||
let is_empty = if let Some(accounts) = accounts.get_mut(&account.address) {
|
||||
if let Some(position) = accounts.iter().position(|acc| acc == account) {
|
||||
accounts.remove(position);
|
||||
}
|
||||
|
@ -358,7 +358,7 @@ impl EthMultiStore {
|
||||
|
||||
// update cache
|
||||
let mut cache = self.cache.write();
|
||||
let mut accounts = cache.entry(account_ref.clone()).or_insert_with(Vec::new);
|
||||
let accounts = cache.entry(account_ref.clone()).or_insert_with(Vec::new);
|
||||
// Remove old account
|
||||
accounts.retain(|acc| acc != &old);
|
||||
// And push updated to the end
|
||||
|
Loading…
Reference in New Issue
Block a user