stupid ass pointer math

pull/6/head
cosmonaut 2023-11-03 16:51:26 -07:00
parent 8774314f62
commit 53f4124fdb
2 changed files with 5 additions and 8 deletions

View File

@ -11,6 +11,7 @@ public unsafe class NativeArray<T> : IDisposable where T : unmanaged
private int Capacity;
private int ElementSize;
public Span<T> ToSpan() => new Span<T>(Elements, Count);
public Span<T>.Enumerator GetEnumerator() => new Span<T>(Elements, Count).GetEnumerator();
private bool disposed;
@ -71,11 +72,7 @@ public unsafe class NativeArray<T> : IDisposable where T : unmanaged
{
if (index != Count - 1)
{
NativeMemory.Copy(
(void*) (Elements + ((Count - 1) * ElementSize)),
(void*) (Elements + (index * ElementSize)),
(nuint) ElementSize
);
this[index] = this[Count - 1];
}
Count -= 1;

View File

@ -171,9 +171,6 @@ internal class RelationStorage
{
var lastElementIndex = relations.Count - 1;
relationDatas.Delete(index);
relations.Delete(index);
// move an element into the hole
if (index != lastElementIndex)
{
@ -181,6 +178,9 @@ internal class RelationStorage
indices[lastRelation] = index;
}
relationDatas.Delete(index);
relations.Delete(index);
indices.Remove(relation);
}