From 4ab38e4c20ad52ea91068b0440a63e135be72933 Mon Sep 17 00:00:00 2001 From: Shane32 Date: Tue, 30 Apr 2024 07:41:24 -0400 Subject: [PATCH] Cache GetCountIndicatorLength --- QRCoder/QRCodeGenerator.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/QRCoder/QRCodeGenerator.cs b/QRCoder/QRCodeGenerator.cs index 240360ac..9dcf172f 100644 --- a/QRCoder/QRCodeGenerator.cs +++ b/QRCoder/QRCodeGenerator.cs @@ -156,9 +156,11 @@ public static QRCodeData GenerateQrCode(string plainText, ECCLevel eccLevel, boo } } + var countIndicatorLength = GetCountIndicatorLength(version, encoding); + var completeBitArrayLength = (eciMode != EciMode.Default ? 16 : 4) + // Mode indicator - GetCountIndicatorLength(version, encoding) + // Count indicator + countIndicatorLength + // Count indicator codedText.Length; // Data var completeBitArray = new BitArray(completeBitArrayLength); @@ -171,7 +173,7 @@ public static QRCodeData GenerateQrCode(string plainText, ECCLevel eccLevel, boo } DecToBin((int)encoding, 4, completeBitArray, ref completeBitArrayIndex); // write count indicator - DecToBin(dataInputLength, GetCountIndicatorLength(version, encoding), completeBitArray, ref completeBitArrayIndex); + DecToBin(dataInputLength, countIndicatorLength, completeBitArray, ref completeBitArrayIndex); // write data for (int i = 0; i < codedText.Length; i++) {