pallet-uniques/nfts: Small optimizations (#2754)

Use `contains_key` to not require decoding the actual value.
This commit is contained in:
Bastian Köcher
2023-12-19 17:17:14 +01:00
committed by GitHub
parent 7c79741e40
commit 84d6342cd2
2 changed files with 4 additions and 4 deletions
@@ -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)?;
},
+2 -2
View File
@@ -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)?;
},