Improve memory safety and alignment handling
Some checks failed
Publish NuGet Packages / publish (pull_request) Failing after 1m5s
Some checks failed
Publish NuGet Packages / publish (pull_request) Failing after 1m5s
- Updated `.gitignore` to include `.vscode/` and clarified comments. - Introduced `SafeHandle` for managing memory alignment and safe access. - Refactored `UnsafeArray<T>` to add bounds checking and alignment logic. - Added `IUnsafeHashCollection<T>` for specialized hash-based collections. - Refactored `UnsafeHashMap<TKey, TValue>` and `UnsafeHashSet<T>` to use `HashMapHelper<TKey>` with alignment support. - Made `UnsafeSlotMap<T>` methods `readonly` for immutability. - Enhanced `HashMapHelper<TKey>` with alignment-aware buffer management and validation. - Updated benchmarks to use `UnsafeArray<Vector256<int>>` and added capacity checks. - Incremented assembly version to `1.1.3` in `Misaki.HighPerformance.LowLevel.csproj`. - Updated `Program.cs` to run `CollectionBenchmark` and demonstrate safe disposal handling.
This commit is contained in:
@@ -206,7 +206,7 @@ public unsafe struct UnsafeSlotMap<T> : IUnsafeCollection<T>
|
||||
/// <param name="value">When this method returns, contains the element at the specified slot and generation if found; otherwise, the
|
||||
/// default value for type <typeparamref name="T"/>.</param>
|
||||
/// <returns>true if the element at the specified slot index and generation is found; otherwise, false.</returns>
|
||||
public bool TryGetElementAt(int slotIndex, int generation, out T value)
|
||||
public readonly bool TryGetElementAt(int slotIndex, int generation, out T value)
|
||||
{
|
||||
if (slotIndex < 0 || slotIndex >= _capacity)
|
||||
{
|
||||
@@ -232,7 +232,7 @@ public unsafe struct UnsafeSlotMap<T> : IUnsafeCollection<T>
|
||||
/// <returns>The element of type <see cref="T"/> stored at the specified slot and generation.</returns>
|
||||
/// <exception cref="ArgumentOutOfRangeException">Thrown when <paramref name="slotIndex"/> is less than zero or greater than or equal to the capacity.</exception>
|
||||
/// <exception cref="InvalidOperationException">Thrown when the specified slot is not occupied or the generation does not match.</exception>
|
||||
public T GetElementAt(int slotIndex, int generation)
|
||||
public readonly T GetElementAt(int slotIndex, int generation)
|
||||
{
|
||||
if (slotIndex < 0 || slotIndex >= _capacity)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user