Refactor core APIs, fix bugs, and improve safety
- Make image result/info structs readonly; improve error handling and memory safety in image library - Introduce IJobScheduler interface; move job scheduling docs to interface - Remove "index 0 invalid" convention from slot/sparse maps; fix Count logic - Add Owner<T> for disposable value types in low-level utilities - Improve ObjectPool<T> thread safety and logic - Change List<T>.RemoveAndSwapBack to return bool - Remove unsafe methods from generated math types; add debug range checks - Update benchmarks and enable collection checks in tests - Improve documentation, comments, and error messages - Bump assembly versions across all projects
This commit is contained in:
@@ -85,7 +85,7 @@ public unsafe struct UnsafeSparseSet<T> : IUnsafeCollection<T>
|
||||
private int _nextId; // Next available sparse index
|
||||
private int _capacity;
|
||||
|
||||
public readonly int Count => _count - 1;
|
||||
public readonly int Count => _count;
|
||||
public readonly int Capacity => _capacity;
|
||||
public readonly bool IsCreated => _dense.IsCreated && _sparse.IsCreated && _reverse.IsCreated;
|
||||
|
||||
@@ -133,8 +133,6 @@ public unsafe struct UnsafeSparseSet<T> : IUnsafeCollection<T>
|
||||
|
||||
_sparse.AsSpan().Fill(-1);
|
||||
_generations.Clear();
|
||||
|
||||
Add(default, out _); // Make index 0 invalid
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -240,8 +238,7 @@ public unsafe struct UnsafeSparseSet<T> : IUnsafeCollection<T>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public readonly bool Contains(int sparseIndex, int generation)
|
||||
{
|
||||
// 0 is reserved as invalid index
|
||||
if (sparseIndex <= 0 || sparseIndex >= _sparse.Count)
|
||||
if (sparseIndex < 0 || sparseIndex >= _sparse.Count)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user