Skip to content

Commit

Permalink
pallet-uniques/nfts: Small optimizations (paritytech#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 authored Dec 19, 2023
1 parent c846f0b commit 4f49519
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 4f49519

Please sign in to comment.