mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-09-23 23:45:14 +00:00
stackalloc addvmcode
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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 =
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user