stupid ass pointer math
parent
8774314f62
commit
53f4124fdb
|
@ -11,6 +11,7 @@ public unsafe class NativeArray<T> : IDisposable where T : unmanaged
|
||||||
private int Capacity;
|
private int Capacity;
|
||||||
private int ElementSize;
|
private int ElementSize;
|
||||||
|
|
||||||
|
public Span<T> ToSpan() => new Span<T>(Elements, Count);
|
||||||
public Span<T>.Enumerator GetEnumerator() => new Span<T>(Elements, Count).GetEnumerator();
|
public Span<T>.Enumerator GetEnumerator() => new Span<T>(Elements, Count).GetEnumerator();
|
||||||
|
|
||||||
private bool disposed;
|
private bool disposed;
|
||||||
|
@ -71,11 +72,7 @@ public unsafe class NativeArray<T> : IDisposable where T : unmanaged
|
||||||
{
|
{
|
||||||
if (index != Count - 1)
|
if (index != Count - 1)
|
||||||
{
|
{
|
||||||
NativeMemory.Copy(
|
this[index] = this[Count - 1];
|
||||||
(void*) (Elements + ((Count - 1) * ElementSize)),
|
|
||||||
(void*) (Elements + (index * ElementSize)),
|
|
||||||
(nuint) ElementSize
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Count -= 1;
|
Count -= 1;
|
||||||
|
|
|
@ -171,9 +171,6 @@ internal class RelationStorage
|
||||||
{
|
{
|
||||||
var lastElementIndex = relations.Count - 1;
|
var lastElementIndex = relations.Count - 1;
|
||||||
|
|
||||||
relationDatas.Delete(index);
|
|
||||||
relations.Delete(index);
|
|
||||||
|
|
||||||
// move an element into the hole
|
// move an element into the hole
|
||||||
if (index != lastElementIndex)
|
if (index != lastElementIndex)
|
||||||
{
|
{
|
||||||
|
@ -181,6 +178,9 @@ internal class RelationStorage
|
||||||
indices[lastRelation] = index;
|
indices[lastRelation] = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
relationDatas.Delete(index);
|
||||||
|
relations.Delete(index);
|
||||||
|
|
||||||
indices.Remove(relation);
|
indices.Remove(relation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue