don't copy array data over itself
parent
c6f8b65b32
commit
0551aa0a07
|
@ -61,10 +61,14 @@ namespace MoonTools.ECS.Collections
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var lastElement = array[Count - 1];
|
|
||||||
var index = indices[element];
|
var index = indices[element];
|
||||||
array[index] = lastElement;
|
|
||||||
indices[lastElement] = index;
|
if (index != Count - 1)
|
||||||
|
{
|
||||||
|
var lastElement = array[Count - 1];
|
||||||
|
array[index] = lastElement;
|
||||||
|
indices[lastElement] = index;
|
||||||
|
}
|
||||||
count -= 1;
|
count -= 1;
|
||||||
indices.Remove(element);
|
indices.Remove(element);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue