Refactor unsafe collections and improve memory handling
Some checks failed
Publish NuGet Packages / publish (pull_request) Has been cancelled
Some checks failed
Publish NuGet Packages / publish (pull_request) Has been cancelled
Refactored enumerators across multiple unsafe collections to use `ref` returns for `Current`, improving performance and reducing memory usage. Enhanced memory management with `AllocationOption` support and optimized resizing logic for collections like `UnsafeBitSet`, `UnsafeSlotMap`, and `UnsafeSparseSet`. Updated `publish-nuget.yaml` to support manual workflow dispatch and trigger on `push`/`pull_request` events. Incremented project version to `1.1.2` and ensured NuGet package generation on build.
This commit is contained in:
@@ -14,41 +14,19 @@ public unsafe struct UnsafeHashMap<TKey, TValue> : IUnsafeCollection<KeyValuePai
|
||||
{
|
||||
internal HashMapHelper<TKey>.Enumerator _enumerator;
|
||||
|
||||
public KeyValuePair<TKey, TValue> Current => _enumerator.GetCurrent<TValue>();
|
||||
object IEnumerator.Current => Current;
|
||||
|
||||
public Enumerator(HashMapHelper<TKey>* data)
|
||||
{
|
||||
_enumerator = new HashMapHelper<TKey>.Enumerator(data);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The current key-value pair.
|
||||
/// </summary>
|
||||
/// <value>The current key-value pair.</value>
|
||||
public KeyValuePair<TKey, TValue> Current
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => _enumerator.GetCurrent<TValue>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the element at the current position of the enumerator in the container.
|
||||
/// </summary>
|
||||
object IEnumerator.Current => Current;
|
||||
|
||||
/// <summary>
|
||||
/// Advances the enumerator to the next key-value pair.
|
||||
/// </summary>
|
||||
/// <returns>True if <see cref="Current"/> is valid to read after the call.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public bool MoveNext() => _enumerator.MoveNext();
|
||||
|
||||
/// <summary>
|
||||
/// Resets the enumerator to its initial state.
|
||||
/// </summary>
|
||||
public void Reset() => _enumerator.Reset();
|
||||
|
||||
/// <summary>
|
||||
/// Does nothing.
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user