Skip to content

Commit 1484a20

Browse files
pscottbkchrkianenigma
authored
Improve overall performance (#6699)
* Improve overall performance * Clean up code Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Remove needless :: Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Remove needless :: Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
1 parent eae62c9 commit 1484a20

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/exec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,7 @@ where
801801

802802
fn rent_allowance(&self) -> BalanceOf<T> {
803803
storage::rent_allowance::<T>(&self.ctx.self_account)
804-
.unwrap_or(<BalanceOf<T>>::max_value()) // Must never be triggered actually
804+
.unwrap_or_else(|_| <BalanceOf<T>>::max_value()) // Must never be triggered actually
805805
}
806806

807807
fn block_number(&self) -> T::BlockNumber { self.block_number }

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ impl<T: Trait> Module<T> {
648648
let cfg = Config::preload();
649649
let vm = WasmVm::new(&cfg.schedule);
650650
let loader = WasmLoader::new(&cfg.schedule);
651-
let mut ctx = ExecutionContext::top_level(origin.clone(), &cfg, &vm, &loader);
651+
let mut ctx = ExecutionContext::top_level(origin, &cfg, &vm, &loader);
652652
func(&mut ctx, gas_meter)
653653
}
654654
}

src/rent.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ fn compute_fee_per_block<T: Trait>(
104104

105105
effective_storage_size
106106
.checked_mul(&T::RentByteFee::get())
107-
.unwrap_or(<BalanceOf<T>>::max_value())
107+
.unwrap_or_else(|| <BalanceOf<T>>::max_value())
108108
}
109109

110110
/// Returns amount of funds available to consume by rent mechanism.
@@ -179,7 +179,7 @@ fn consider_case<T: Trait>(
179179

180180
let dues = fee_per_block
181181
.checked_mul(&blocks_passed.saturated_into::<u32>().into())
182-
.unwrap_or(<BalanceOf<T>>::max_value());
182+
.unwrap_or_else(|| <BalanceOf<T>>::max_value());
183183
let insufficient_rent = rent_budget < dues;
184184

185185
// If the rent payment cannot be withdrawn due to locks on the account balance, then evict the

0 commit comments

Comments
 (0)