From 84d6342cd26f1c2427558477fa1586319ce14677 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Tue, 19 Dec 2023 17:17:14 +0100 Subject: [PATCH] pallet-uniques/nfts: Small optimizations (#2754) Use `contains_key` to not require decoding the actual value. --- substrate/frame/nfts/src/features/transfer.rs | 4 ++-- substrate/frame/uniques/src/lib.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/substrate/frame/nfts/src/features/transfer.rs b/substrate/frame/nfts/src/features/transfer.rs index ac73d283ee..bba834483e 100644 --- a/substrate/frame/nfts/src/features/transfer.rs +++ b/substrate/frame/nfts/src/features/transfer.rs @@ -173,8 +173,8 @@ impl, I: 'static> Pallet { who: T::AccountId, maybe_collection: Option, ) -> DispatchResult { - let old = OwnershipAcceptance::::get(&who); - match (old.is_some(), maybe_collection.is_some()) { + let exists = OwnershipAcceptance::::contains_key(&who); + match (exists, maybe_collection.is_some()) { (false, true) => { frame_system::Pallet::::inc_consumers(&who)?; }, diff --git a/substrate/frame/uniques/src/lib.rs b/substrate/frame/uniques/src/lib.rs index 253a318e47..f7cc6b044d 100644 --- a/substrate/frame/uniques/src/lib.rs +++ b/substrate/frame/uniques/src/lib.rs @@ -1433,8 +1433,8 @@ pub mod pallet { maybe_collection: Option, ) -> DispatchResult { let who = ensure_signed(origin)?; - let old = OwnershipAcceptance::::get(&who); - match (old.is_some(), maybe_collection.is_some()) { + let exists = OwnershipAcceptance::::contains_key(&who); + match (exists, maybe_collection.is_some()) { (false, true) => { frame_system::Pallet::::inc_consumers(&who)?; },