Skip to content

Commit

Permalink
nullref
Browse files Browse the repository at this point in the history
  • Loading branch information
andreakarasho committed May 17, 2024
1 parent 1d66ae8 commit 649ee59
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/Archetype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ public readonly ref EntityView EntityAt(int row)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly ref T GetReference<T>(int column) where T : struct
{
if (column < 0 || column >= Components!.Length) return ref Unsafe.NullRef<T>();
if (column < 0 || column >= Components!.Length)
return ref Unsafe.NullRef<T>();

//EcsAssert.Assert(column >= 0 && column < Components!.Length);
ref var array = ref Unsafe.As<Array, T[]>(ref Components![column]);
#if NET
return ref MemoryMarshal.GetArrayDataReference(array);
Expand All @@ -32,8 +32,9 @@ public readonly ref T GetReference<T>(int column) where T : struct
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly Span<T> GetSpan<T>(int column) where T : struct
{
if (column < 0 || column >= Components!.Length) return Array.Empty<T>();
//EcsAssert.Assert(column >= 0 && column < Components!.Length);
if (column < 0 || column >= Components!.Length)
return MemoryMarshal.CreateSpan(ref Unsafe.NullRef<T>(), 1);

ref var array = ref Unsafe.As<Array, T[]>(ref Components![column]);
return array.AsSpan(0, Count);
}
Expand Down

0 comments on commit 649ee59

Please sign in to comment.