working on dynamic wrapping

This commit is contained in:
Youmu Liu
2025-11-06 18:12:04 +08:00
parent ea0e6f3ff6
commit ec1b8dbd51
9 changed files with 145 additions and 612 deletions
@@ -105,7 +105,7 @@ namespace StgSharp.Collections
public T[] PopRange(int count)
{
if (count <= 0) {
return Array.Empty<T>();
return [];
}
T[] result = new T[count];
@@ -122,7 +122,7 @@ namespace StgSharp.Collections
}
if (i == 0) {
return Array.Empty<T>();
return [];
}
T[] trimmed = new T[i];
@@ -251,7 +251,7 @@ namespace StgSharp.Collections
if (Volatile.Read(ref _states[newTop]) == 0)
{
// attempt to restore top; ok if it fails due to concurrent operations
Interlocked.CompareExchange(ref _top, newTop + 1, newTop);
_ = Interlocked.CompareExchange(ref _top, newTop + 1, newTop);
sw.SpinOnce();
continue;
}
@@ -259,7 +259,7 @@ namespace StgSharp.Collections
value = _values[newTop];
_values[newTop] = default!; // avoid ref retention
Volatile.Write(ref _states[newTop], 0); // mark empty
Interlocked.Decrement(ref _count);
_ = Interlocked.Decrement(ref _count);
return true;
}
}