How to optimize a for loop/search function?

Something that you must do is cache the GetAllChildren result to a temporary variable and loop through that variable
Otherwise your for loop will call GetAllChildren in every loop which will add a lot to the overall cost

Also if you feel confident with C++, loops are many times faster in C++, especially as the number of iterations increases

1 Like