don't copy array data over itself

pull/6/head
cosmonaut 2023-11-07 18:12:42 -08:00
parent c6f8b65b32
commit 0551aa0a07
1 changed files with 7 additions and 3 deletions

View File

@ -61,10 +61,14 @@ namespace MoonTools.ECS.Collections
return false;
}
var lastElement = array[Count - 1];
var index = indices[element];
if (index != Count - 1)
{
var lastElement = array[Count - 1];
array[index] = lastElement;
indices[lastElement] = index;
}
count -= 1;
indices.Remove(element);