Skip to content

Commit

Permalink
pallet-uniques/nfts: Small optimizations
Browse files Browse the repository at this point in the history
Use `contains_key` to not require decoding the actual value.
  • Loading branch information
bkchr committed Dec 19, 2023
1 parent 526c81b commit feb63c9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions substrate/frame/nfts/src/features/transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
who: T::AccountId,
maybe_collection: Option<T::CollectionId>,
) -> DispatchResult {
let old = OwnershipAcceptance::<T, I>::get(&who);
match (old.is_some(), maybe_collection.is_some()) {
let exists = OwnershipAcceptance::<T, I>::contains_key(&who);
match (exists, maybe_collection.is_some()) {
(false, true) => {
frame_system::Pallet::<T>::inc_consumers(&who)?;
},
Expand Down
4 changes: 2 additions & 2 deletions substrate/frame/uniques/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1430,8 +1430,8 @@ pub mod pallet {
maybe_collection: Option<T::CollectionId>,
) -> DispatchResult {
let who = ensure_signed(origin)?;
let old = OwnershipAcceptance::<T, I>::get(&who);
match (old.is_some(), maybe_collection.is_some()) {
let exists = OwnershipAcceptance::<T, I>::contains_key(&who);
match (exists, maybe_collection.is_some()) {
(false, true) => {
frame_system::Pallet::<T>::inc_consumers(&who)?;
},
Expand Down

0 comments on commit feb63c9

Please sign in to comment.