diff --git a/crates/sargon/src/wrapped_radix_engine_toolkit/high_level/manifest_building/account_locker/manifest_account_locker.rs b/crates/sargon/src/wrapped_radix_engine_toolkit/high_level/manifest_building/account_locker/manifest_account_locker.rs index 1e11821dd..a820cd03a 100644 --- a/crates/sargon/src/wrapped_radix_engine_toolkit/high_level/manifest_building/account_locker/manifest_account_locker.rs +++ b/crates/sargon/src/wrapped_radix_engine_toolkit/high_level/manifest_building/account_locker/manifest_account_locker.rs @@ -65,22 +65,18 @@ impl TransactionManifest { size: usize, ) -> Vec { let mut current_batch_size = 0; - let mut claimable_resources_batch: Vec = - Vec::with_capacity(size); - for claimable in claimable_resources { - current_batch_size += match &claimable { - AccountLockerClaimableResource::Fungible { .. } => 1, - AccountLockerClaimableResource::NonFungible { ids, .. } => { - ids.len() - } - }; - if current_batch_size < size { - claimable_resources_batch.push(claimable); - } else { - break; - } - } - claimable_resources_batch + claimable_resources + .into_iter() + .take_while(|claimable| { + current_batch_size += match claimable { + AccountLockerClaimableResource::Fungible { .. } => 1, + AccountLockerClaimableResource::NonFungible { + ids, .. + } => ids.len(), + }; + current_batch_size < size + }) + .collect() } }