Skip to content

Commit

Permalink
Short circuit token::transfer if amount is zero
Browse files Browse the repository at this point in the history
  • Loading branch information
james-chf authored and tzemanovic committed Mar 30, 2023
1 parent c2d6105 commit 626548d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions core/src/ledger/storage_api/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ pub fn transfer<S>(
where
S: StorageRead + StorageWrite,
{
if amount.is_zero() {
return Ok(());
}
let src_key = token::balance_key(token, src);
let src_balance = read_balance(storage, token, src)?;
match src_balance.checked_sub(amount) {
Expand Down

0 comments on commit 626548d

Please sign in to comment.