Skip to content

Commit

Permalink
pallet-uniques/nfts: Small optimizations (#2754)
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 7c79741 commit 84d6342
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 @@ -173,8 +173,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 @@ -1433,8 +1433,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 84d6342

Please sign in to comment.