Skip to content

Commit 4e82c99

Browse files
committed
Performance update on GenerateQrCode function
1 parent cecf206 commit 4e82c99

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

QRCoder/QRCodeGenerator.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,16 @@ public static QRCodeData GenerateQrCode(byte[] binaryData, ECCLevel eccLevel)
172172
string modeIndicator = DecToBin((int)EncodingMode.Byte, 4);
173173
string countIndicator = DecToBin(binaryData.Length, GetCountIndicatorLength(version, EncodingMode.Byte));
174174

175-
string bitString = modeIndicator + countIndicator;
175+
string bitString = "";
176+
StringBuilder sb = new StringBuilder();
177+
sb.Append(modeIndicator + countIndicator);
176178
foreach (byte b in binaryData)
177179
{
178-
bitString += DecToBin(b, 8);
180+
sb.Append(DecToBin(b, 8));
181+
179182
}
183+
bitString = sb.ToString();
184+
180185

181186
return GenerateQrCode(bitString, eccLevel, version);
182187
}

0 commit comments

Comments
 (0)