Refactor and enhance math and utility libraries
Some checks failed
Publish NuGet Packages / publish (push) Failing after 3m12s

Refactored `sincos` usage across `quaternion` and `random` to use `out` parameters for improved performance. Enhanced `random` struct with updated random direction generation methods.

Added new benchmarks in `MathematicsBenchmark` for vector operations, including SIMD-based `f4` struct. Downgraded target framework to `net9.0` for compatibility.

Introduced `ReadOnlyUnsafeCollection` for low-level memory management. Added utility methods in `CollectionUtility` for span creation and optimized list operations.

Renamed `MemoryUtilities` to `MemoryUtility` and updated all references. Enhanced `ObjectPool` with `Rent` and `TryRent` methods. Enabled `AllowUnsafeBlocks` and AOT compatibility in project configuration.

Performed general code cleanup, including removal of unused methods, improved formatting, and alignment with modern coding practices.
This commit is contained in:
2025-11-04 14:53:01 +09:00
parent 081103372f
commit 49e1171781
38 changed files with 5149 additions and 1259 deletions

View File

@@ -41,7 +41,7 @@ public unsafe struct HashMapHelper<TKey> : IDisposable
public KeyValuePair<TKey, TValue> GetCurrent<TValue>()
where TValue : unmanaged
{
return new KeyValuePair<TKey, TValue>(buffer->_keys[index], UnsafeUtilities.ReadArrayElementRef<TValue>(buffer->_buffer, index));
return new KeyValuePair<TKey, TValue>(buffer->_keys[index], UnsafeUtility.ReadArrayElementRef<TValue>(buffer->_buffer, index));
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -246,7 +246,7 @@ public unsafe struct HashMapHelper<TKey> : IDisposable
if ((uint)entryIdx < (uint)_capacity)
{
var nextPtrs = _next;
while (!UnsafeUtilities.ReadArrayElement<TKey>(_keys, entryIdx).Equals(key))
while (!UnsafeUtility.ReadArrayElement<TKey>(_keys, entryIdx).Equals(key))
{
entryIdx = nextPtrs[entryIdx];
if ((uint)entryIdx >= (uint)_capacity)
@@ -292,7 +292,7 @@ public unsafe struct HashMapHelper<TKey> : IDisposable
CheckIndexOutOfBounds(idx);
UnsafeUtilities.WriteArrayElement(_keys, idx, key);
UnsafeUtility.WriteArrayElement(_keys, idx, key);
var bucket = GetBucket(key);
// Add the index to the hash-map
@@ -321,7 +321,7 @@ public unsafe struct HashMapHelper<TKey> : IDisposable
while (entryIdx >= 0 && entryIdx < _capacity)
{
if (UnsafeUtilities.ReadArrayElement<TKey>(_keys, entryIdx).Equals(key))
if (UnsafeUtility.ReadArrayElement<TKey>(_keys, entryIdx).Equals(key))
{
removed++;
@@ -361,7 +361,7 @@ public unsafe struct HashMapHelper<TKey> : IDisposable
if (idx != -1)
{
item = UnsafeUtilities.ReadArrayElement<TValue>(_buffer, idx);
item = UnsafeUtility.ReadArrayElement<TValue>(_buffer, idx);
return true;
}
@@ -414,7 +414,7 @@ public unsafe struct HashMapHelper<TKey> : IDisposable
while (bucket != -1)
{
result[count++] = UnsafeUtilities.ReadArrayElement<TKey>(_keys, bucket);
result[count++] = UnsafeUtility.ReadArrayElement<TKey>(_keys, bucket);
bucket = _next[bucket];
}
}
@@ -433,7 +433,7 @@ public unsafe struct HashMapHelper<TKey> : IDisposable
while (bucket != -1)
{
result[count++] = UnsafeUtilities.ReadArrayElement<TValue>(_buffer, bucket);
result[count++] = UnsafeUtility.ReadArrayElement<TValue>(_buffer, bucket);
bucket = _next[bucket];
}
}
@@ -452,8 +452,8 @@ public unsafe struct HashMapHelper<TKey> : IDisposable
while (bucket != -1)
{
result[count] = new(UnsafeUtilities.ReadArrayElement<TKey>(_keys, bucket),
UnsafeUtilities.ReadArrayElement<TValue>(_buffer, bucket));
result[count] = new(UnsafeUtility.ReadArrayElement<TKey>(_keys, bucket),
UnsafeUtility.ReadArrayElement<TValue>(_buffer, bucket));
count++;
bucket = _next[bucket];