stackalloc addvmcode

This commit is contained in:
majorro
2025-01-13 23:31:33 +03:00
parent 91364c6a7c
commit 23e1447ab6
3 changed files with 5 additions and 5 deletions

View File

@@ -9,7 +9,7 @@ internal static class RarCRC
public static uint CheckCrc(uint startCrc, byte b) =>
(crcTab[((int)startCrc ^ b) & 0xff] ^ (startCrc >> 8));
public static uint CheckCrc(uint startCrc, byte[] data, int offset, int count)
public static uint CheckCrc(uint startCrc, ReadOnlySpan<byte> data, int offset, int count)
{
var size = Math.Min(data.Length - offset, count);

View File

@@ -1197,7 +1197,7 @@ internal sealed partial class Unpack : BitInput, IRarUnpack, IDisposable
{
return (false);
}
var VMCode = new byte[VMCodeSize];
Span<byte> VMCode = stackalloc byte[VMCodeSize];
for (var I = 0; I < VMCodeSize; I++)
{
if (Inp.Overflow(3))

View File

@@ -776,14 +776,14 @@ internal sealed class RarVM : BitInput
}
}
public void prepare(byte[] code, int codeSize, VMPreparedProgram prg)
public void prepare(ReadOnlySpan<byte> code, int codeSize, VMPreparedProgram prg)
{
InitBitInput();
var cpLength = Math.Min(MAX_SIZE, codeSize);
// memcpy(inBuf,Code,Min(CodeSize,BitInput::MAX_SIZE));
Buffer.BlockCopy(code, 0, InBuf, 0, cpLength);
code.Slice(0, cpLength).CopyTo(InBuf);
byte xorSum = 0;
for (var i = 1; i < codeSize; i++)
{
@@ -1105,7 +1105,7 @@ internal sealed class RarVM : BitInput
}
}
private VMStandardFilters IsStandardFilter(byte[] code, int codeSize)
private VMStandardFilters IsStandardFilter(ReadOnlySpan<byte> code, int codeSize)
{
VMStandardFilterSignature[] stdList =
{