fix: Fixes STArray size and tests (#1737)
This commit is contained in:
parent
3a27ab8810
commit
7a160bb0fd
2 changed files with 7 additions and 8 deletions
|
|
@ -36,12 +36,11 @@ public class STArrayPoolTests
|
|||
{
|
||||
STArrayPool<byte>.Shared.ResetForTesting();
|
||||
|
||||
var cores = Environment.ProcessorCount;
|
||||
var arrays1 = new byte[cores * 8 + 2][]; // 1 for the cache, and 8 * CPU for the stacks
|
||||
var weakReferences1 = new WeakReference[cores * 8 + 2];
|
||||
var arrays1 = new byte[32 + 2][]; // 1 for the cache, 32 for the cores, and 1 for overflow
|
||||
var weakReferences1 = new WeakReference[32 + 2];
|
||||
|
||||
var arrays2 = new byte[cores * 8 + 2][]; // 1 for the cache, and 8 * CPU for the stacks
|
||||
var weakReferences2 = new WeakReference[cores * 8 + 2];
|
||||
var arrays2 = new byte[32 + 2][];
|
||||
var weakReferences2 = new WeakReference[32 + 2];
|
||||
|
||||
for (var i = 0; i < arrays1.Length; i++)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ public class STArrayPool<T> : ArrayPool<T>
|
|||
if (minimumLength == 0)
|
||||
{
|
||||
// We aren't renting.
|
||||
return Array.Empty<T>();
|
||||
return [];
|
||||
}
|
||||
|
||||
if (minimumLength < 0)
|
||||
|
|
@ -74,7 +74,7 @@ public class STArrayPool<T> : ArrayPool<T>
|
|||
return buffer;
|
||||
}
|
||||
|
||||
public override void Return(T[] array, bool clearArray = false)
|
||||
public override void Return(T[]? array, bool clearArray = false)
|
||||
{
|
||||
if (array is null)
|
||||
{
|
||||
|
|
@ -231,7 +231,7 @@ public class STArrayPool<T> : ArrayPool<T>
|
|||
private sealed class STArrayStack
|
||||
{
|
||||
// Maximum buffers we will store in our stack
|
||||
private readonly T[][] _arrays = new T[StackArraySize * Environment.ProcessorCount][];
|
||||
private readonly T[][] _arrays = new T[StackArraySize][];
|
||||
private int _count;
|
||||
private long _ticks;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue