From d54495d7ecff16f527eee6958befbb5f06db0f9d Mon Sep 17 00:00:00 2001 From: Robin van Poppel Date: Sat, 11 Apr 2020 17:07:01 +0200 Subject: [PATCH] Replace Count(xxx) > 0 with Any() --- .../Libraries/QRCoder/QRCodeGenerator.cs | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/KeeTrayTOTP/Libraries/QRCoder/QRCodeGenerator.cs b/KeeTrayTOTP/Libraries/QRCoder/QRCodeGenerator.cs index c5586fd..dd1c9a8 100644 --- a/KeeTrayTOTP/Libraries/QRCoder/QRCodeGenerator.cs +++ b/KeeTrayTOTP/Libraries/QRCoder/QRCodeGenerator.cs @@ -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) @@ -914,7 +909,7 @@ private int GetCountIndicatorLength(int version, EncodingMode encMode) return 11; case EncodingMode.Byte: return 16; - default: + default: return 10; } }