Skip to content

Commit

Permalink
Replace Count(xxx) > 0 with Any()
Browse files Browse the repository at this point in the history
  • Loading branch information
robinvanpoppel committed Apr 11, 2020
1 parent cfe912f commit d54495d
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions KeeTrayTOTP/Libraries/QRCoder/QRCodeGenerator.cs
Expand Up @@ -788,18 +788,13 @@ private Polynom ConvertToDecNotation(Polynom poly)

private int GetVersion(int length, EncodingMode encMode, ECCLevel eccLevel)
{
return this.capacityTable.Where(
x => x.Details.Count(
y => (y.ErrorCorrectionLevel == eccLevel
&& y.CapacityDict[encMode] >= Convert.ToInt32(length)
)
) > 0
).Select(x => new
{
version = x.Version,
capacity = x.Details.Single(y => y.ErrorCorrectionLevel == eccLevel)
.CapacityDict[encMode]
}).Min(x => x.version);
return this.capacityTable
.Where(x => x.Details.Any(y => y.ErrorCorrectionLevel == eccLevel && y.CapacityDict[encMode] >= Convert.ToInt32(length)))
.Select(x => new
{
version = x.Version,
capacity = x.Details.Single(y => y.ErrorCorrectionLevel == eccLevel).CapacityDict[encMode]
}).Min(x => x.version);
}

private EncodingMode GetEncodingFromPlaintext(string plainText, bool forceUtf8)
Expand Down Expand Up @@ -914,7 +909,7 @@ private int GetCountIndicatorLength(int version, EncodingMode encMode)
return 11;
case EncodingMode.Byte:
return 16;
default:
default:
return 10;
}
}
Expand Down

0 comments on commit d54495d

Please sign in to comment.