From ce5dc7c1a127e9958c12c0d38536c02a147629d1 Mon Sep 17 00:00:00 2001 From: Jason Nelson Date: Mon, 1 Apr 2024 21:46:06 -0700 Subject: [PATCH] Eliminate byte[] allocation in RC4 --- src/UglyToad.PdfPig/Encryption/RC4.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/UglyToad.PdfPig/Encryption/RC4.cs b/src/UglyToad.PdfPig/Encryption/RC4.cs index 2664139a0..146e6054c 100644 --- a/src/UglyToad.PdfPig/Encryption/RC4.cs +++ b/src/UglyToad.PdfPig/Encryption/RC4.cs @@ -7,7 +7,7 @@ internal static class RC4 public static byte[] Encrypt(ReadOnlySpan key, ReadOnlySpan data) { // Key-scheduling algorithm - var s = new byte[256]; + Span s = stackalloc byte[256]; for (var i = 0; i < 256; i++) { s[i] = (byte)i;