Small performance improvements of IEnumerables
Using lists to avoid multiple enumeration.
Removed unnecessary ToArray call.
MODIFY
WalletWasabi/Models/ChaumianCoinJoin/CcjRound.cs
WalletWasabi/Models/ChaumianCoinJoin/CcjRound.cs
@@ -399,7 +399,7 @@ namespace WalletWasabi.Models.ChaumianCoinJoin
IEnumerable<Alice> alicesToBan1 = GetAlicesBy(AliceState.InputsRegistered);
IEnumerable<Alice> alicesToBan2 = await RemoveAlicesIfInputsSpentAsync(); // So ban only those who confirmed participation, yet spent their inputs.
- IEnumerable<OutPoint> inputsToBan = alicesToBan1.SelectMany(x => x.Inputs).Select(y => y.OutPoint).Concat(alicesToBan2.SelectMany(x => x.Inputs).Select(y => y.OutPoint).ToArray()).Distinct();
+ IEnumerable<OutPoint> inputsToBan = alicesToBan1.SelectMany(x => x.Inputs).Select(y => y.OutPoint).Concat(alicesToBan2.SelectMany(x => x.Inputs).Select(y => y.OutPoint)).Distinct();
if (inputsToBan.Any())
{

MODIFY
WalletWasabi/Services/CcjClient.cs
WalletWasabi/Services/CcjClient.cs
@@ -336,11 +336,11 @@ namespace WalletWasabi.Services
{
try
{
- IEnumerable<(uint256 txid, uint index)> registrableCoins = State.GetRegistrableCoins(
+ List<(uint256 txid, uint index)> registrableCoins = State.GetRegistrableCoins(
inputRegistrableRound.State.MaximumInputCountPerPeer,
inputRegistrableRound.State.Denomination,
inputRegistrableRound.State.FeePerInputs,
- inputRegistrableRound.State.FeePerOutputs);
+ inputRegistrableRound.State.FeePerOutputs).ToList();
if (registrableCoins.Any())
{

MODIFY
WalletWasabi/Services/WalletService.cs
WalletWasabi/Services/WalletService.cs
@@ -300,7 +300,10 @@ namespace WalletWasabi.Services
}
// If double spend:
- IEnumerable<SmartCoin> doubleSpends = Coins.Where(x => tx.Transaction.Inputs.Any(y => x.SpentOutputs.Select(z => z.ToOutPoint()).Contains(y.PrevOut)));
+ List<SmartCoin> doubleSpends = Coins
+ .Where(x => tx.Transaction.Inputs.Any(y => x.SpentOutputs.Select(z => z.ToOutPoint()).Contains(y.PrevOut)))
+ .ToList();
+
if (doubleSpends.Any())
{
if (tx.Height == Height.MemPool)

Small performance improvements of IEnumerables

Using lists to avoid multiple enumeration.
Removed unnecessary ToArray call.