Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
Shane32 authored May 5, 2024
1 parent 20dd5a2 commit cf29ca3
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions QRCoder/QRCodeGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -416,15 +416,16 @@ private static BitArray GetVersionString(int version)
/// </summary>
private static byte[] CalculateECCWords(BitArray bitArray, int offset, int count, ECCInfo eccInfo)
{
var eccWords = eccInfo.ECCPerBlock;
// Calculate the message polynomial from the bit array data.
var messagePolynom = CalculateMessagePolynom(bitArray, offset, count);
// Generate the generator polynomial using the number of ECC words.
var generatorPolynom = CalculateGeneratorPolynom(eccInfo.ECCPerBlock);
var generatorPolynom = CalculateGeneratorPolynom(eccWords);

// Adjust the exponents in the message polynomial to account for ECC length.
for (var i = 0; i < messagePolynom.PolyItems.Count; i++)
messagePolynom.PolyItems[i] = new PolynomItem(messagePolynom.PolyItems[i].Coefficient,
messagePolynom.PolyItems[i].Exponent + eccInfo.ECCPerBlock);
messagePolynom.PolyItems[i].Exponent + eccWords);

// Adjust the generator polynomial exponents based on the message polynomial.
for (var i = 0; i < generatorPolynom.PolyItems.Count; i++)
Expand Down Expand Up @@ -1042,10 +1043,10 @@ int[] GetNotUniqueExponents(List<PolynomItem> list)
if (dic.TryAdd(row.Exponent, false))
dic[row.Exponent] = true;
#else
if (!dic.ContainsKey(row.Exponent))
dic.Add(row.Exponent, false);
else
dic[row.Exponent] = true;
if (!dic.ContainsKey(row.Exponent))
dic.Add(row.Exponent, false);
else
dic[row.Exponent] = true;
#endif
}

Expand Down

0 comments on commit cf29ca3

Please sign in to comment.