Use spans to improve performance in StreamExts.
Also avoid ReadBytes calls that allocate a buffer by either updating the stream position (if not interested in the bytes), by reusing an input buffer (if interested in the bytes), or using a stackalloc buffer to avoid the allocation (for small reads).
This commit is contained in:
@@ -20,11 +20,11 @@ namespace OpenRA.Mods.Common.FileFormats
|
||||
static readonly int[] AudWsStepTable2 = { -2, -1, 0, 1 };
|
||||
static readonly int[] AudWsStepTable4 = { -9, -8, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 8 };
|
||||
|
||||
public static void DecodeWestwoodCompressedSample(byte[] input, byte[] output)
|
||||
public static void DecodeWestwoodCompressedSample(ReadOnlySpan<byte> input, Span<byte> output)
|
||||
{
|
||||
if (input.Length == output.Length)
|
||||
{
|
||||
Array.Copy(input, output, output.Length);
|
||||
input.CopyTo(output);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user