Skip to content

Commit

Permalink
- Added tests covering Enumerator.
Browse files Browse the repository at this point in the history
 - Removed constructor which made it easy to read out of the valid span range.
  - Only used in one place, fixed that call site.
  • Loading branch information
martindevans committed Oct 28, 2023
1 parent c7f59a9 commit 1e88b09
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 17 deletions.
2 changes: 1 addition & 1 deletion src/Arch/Core/Archetype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ internal void SetRange<T>(in Slot from, in Slot to, in T? component = default)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Enumerator<Chunk> GetEnumerator()
{
return new Enumerator<Chunk>(Chunks.AsSpan(), Size);
return new Enumerator<Chunk>(Chunks.AsSpan(0, Size));
}

/// <summary>
Expand Down
16 changes: 0 additions & 16 deletions src/Arch/Core/Enumerators.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,6 @@ public Enumerator(Span<T> span)
_index = _length;
}

/// <summary>
/// Initializes a new instance of the <see cref="Enumerator{T}"/> struct.
/// </summary>
/// <param name="span">The <see cref="Span{T}"/> with items to iterate over.</param>
/// <param name="length">Its length or size.</param>
public Enumerator(Span<T> span, int length)
{
#if NET7_0_OR_GREATER
_ptr = ref MemoryMarshal.GetReference(span);
#else
_ptr = new Ref<T>(ref span.DangerousGetReference());
#endif
_length = length;
_index = _length;
}

/// <summary>
/// Moves to the next item.
/// </summary>
Expand Down

0 comments on commit 1e88b09

Please sign in to comment.