Skip to content

Commit

Permalink
Using stackalloc instead of heap array
Browse files Browse the repository at this point in the history
  • Loading branch information
lookbusy1344 committed Nov 18, 2023
1 parent 03e6a03 commit 0609eb3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ public static bool IsZipArchive(string filePath)
{
try
{
var fileBytes = new byte[MagicNumberZip.Length];
Span<byte> fileBytes = stackalloc byte[MagicNumberZip.Length];

using var file = new FileStream(filePath, FileMode.Open, FileAccess.Read);
_ = file.Read(fileBytes, 0, fileBytes.Length);
_ = file.Read(fileBytes);

return fileBytes.SequenceEqual(MagicNumberZip);
}
Expand Down

0 comments on commit 0609eb3

Please sign in to comment.