rmrk-team / rmrk-substrate

[WIP] RMRK Substrate pallets
https://rmrk.app
Other
74 stars 36 forks source link

Replace drain_prefix for loop with remove_prefix #130

Closed HashWarlock closed 2 years ago

HashWarlock commented 2 years ago

In the current code we have examples where we use drain_prefix and run a for loop on the iterator without doing anything.

Here is an example of this on line 319: https://github.com/rmrk-team/rmrk-substrate/blob/ead0e1e8c64ec00518f9472b0facd05c4a010743/pallets/rmrk-core/src/functions.rs#L319 Instead we can change it to this and avoid iterating through the Resources:

Resources::<T>::remove_prefix((collection_id, nft_id), None);

Suggestion to remove all instances where we iterate through the drain_prefix Iterator & replace with remove_prefix to avoid unnecessary iteration.

bmacer commented 2 years ago

https://github.com/rmrk-team/rmrk-substrate/pull/135 look good?