Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance: Using count/length property instead of count method is faster, less overhead #1721

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public async Task<IActionResult> PostInputsAsync([FromBody, Required]InputsReque
}
if (Coordinator.AnyRunningRoundContainsInput(inputProof.Input.ToOutPoint(), out List<Alice> tnr))
{
if (tr.Union(tnr).Count() > tr.Count())
if (tr.Union(tnr).Count() > tr.Count)
{
return BadRequest("Input is already registered in another round.");
}
Expand Down Expand Up @@ -257,7 +257,7 @@ public async Task<IActionResult> PostInputsAsync([FromBody, Required]InputsReque
var acceptedBlindedOutputScripts = new List<uint256>();

// Calculate expected networkfee to pay after base denomination.
int inputCount = inputs.Count();
int inputCount = inputs.Count;
Money networkFeeToPayAfterBaseDenomination = (inputCount * round.FeePerInputs) + (2 * round.FeePerOutputs);

// Check if inputs have enough coins.
Expand Down
2 changes: 1 addition & 1 deletion WalletWasabi.Packager/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ private static void Publish()
foreach (var file in assetsInfo.EnumerateFiles())
{
var number = file.Name.Split(new string[] { "WasabiLogo", ".png" }, StringSplitOptions.RemoveEmptyEntries);
if (number.Count() == 1 && int.TryParse(number.First(), out int size))
if (number.Length == 1 && int.TryParse(number.First(), out int size))
{
string destFolder = Path.Combine(debUsrShareIconsFolderPath, $"{size}x{size}", "apps");
Directory.CreateDirectory(destFolder);
Expand Down
2 changes: 1 addition & 1 deletion WalletWasabi/Models/ChaumianCoinJoin/CcjRound.cs
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ private bool CanUseAdditionalOutputs(Money newDenomination)

if (changeAmount < Money.Zero)
{
if (acceptedBlindedOutputScriptsCount < alice.BlindedOutputScripts.Count())
if (acceptedBlindedOutputScriptsCount < alice.BlindedOutputScripts.Length)
{
tinkerWithAdditionalMixingLevels = false;
}
Expand Down
6 changes: 3 additions & 3 deletions WalletWasabi/Models/ChaumianCoinJoin/MixingLevels.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using NBitcoin;
using NBitcoin;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -76,7 +76,7 @@ public IEnumerable<SchnorrPubKey> SchnorrPubKeys
{
get
{
if (_schnorrPubKeys?.Count() != Levels?.Count()) // Signing keys don't change, but more levels may be added. (Although even that's unlikely.)
if (_schnorrPubKeys?.Count() != Levels?.Count) // Signing keys don't change, but more levels may be added. (Although even that's unlikely.)
{
_schnorrPubKeys = Levels.Select(x => x.Signer.GetSchnorrPubKey());
}
Expand All @@ -85,6 +85,6 @@ public IEnumerable<SchnorrPubKey> SchnorrPubKeys
set { _schnorrPubKeys = value; }
}

public int GetMaxLevel() => Levels.Count() - 1;
public int GetMaxLevel() => Levels.Count - 1;
}
}
2 changes: 1 addition & 1 deletion WalletWasabi/Services/WalletService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ await BitcoinStore.IndexStore.ForeachFiltersAsync(async (filterModel) =>
}
}

if (cnt != unconfirmedTransactions.Count())
if (cnt != unconfirmedTransactions.Length)
{
SerializeTransactionCache();
}
Expand Down