Skip to content

Commit e08d6e3

Browse files
committed
Update comments
1 parent 27f29c3 commit e08d6e3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

QRCoder/QRCodeGenerator.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -934,8 +934,10 @@ private static BitArray PlainTextToBinaryByte(string plainText, EciMode eciMode,
934934
}
935935
}
936936

937-
#if NET5_0_OR_GREATER
938-
// In .NET 5.0 and later, we can use stackalloc for small arrays to prevent heap allocations
937+
#if NETCOREAPP2_1_OR_GREATER
938+
// We can use stackalloc for small arrays to prevent heap allocations
939+
// (also available in .NET Standard and .NET Framework with an additional NuGet dependency)
940+
// Note that all QR codes should fit within 3000 bytes, so this code should never trigger a heap allocation unless an exception will be thrown anyway.
939941
int count = targetEncoding.GetByteCount(plainText);
940942
Span<byte> codeBytes = count < 3000 ? stackalloc byte[count] : new byte[count];
941943
targetEncoding.GetBytes(plainText, codeBytes);

0 commit comments

Comments
 (0)