Arrays: (performance) remove Index vs remove Item

Hey, which is preferable to use by performance over the other?

It seems like “by index” should be faster, but let’s make sure just for the sake of perfection.

Thank you.

Remove by index is faster.

However it will be bounded on a way how do you find the index.

Remove item will iterate the whole thing check the “==” and if so will remove it.

In remove by index it will bypass the iteration and only remove the item at index.

Clarification:

if you will iterate the array and then find indeces by your self the performance will be roughly the same (but in favor of remove item - since less function calls will be issued also they could possibly iterate faster (there are some iteration optimizations existing in C/C++ languages which Epic developers could utilize - or not it is worth to check the engine’s source) ).

To sum this up:

RemovebyIndex is O(1)

RemoveItem is O(n)

(Not really O(1) / O(n) since array makes internal re-allocations but we can relate to it as O(1) / O(n).