This refactor of the root_game_objects doubles its performance by avoiding looping through the List of GameObjects twice.
The previous implementation used to loop once to count the number of elements, only for looping again a second time to get the memory pointers. This is effectively unneded as the number of objects can be inferred by the number of elements in the iterator, and wastes computing time to winapi calls.
This also helps improving performance while looping for objects through the linked list of Transforms in a Unity scene, a very cpu intensive process.
This refactor of the
root_game_objects
doubles its performance by avoiding looping through theList
ofGameObjects
twice.The previous implementation used to loop once to count the number of elements, only for looping again a second time to get the memory pointers. This is effectively unneded as the number of objects can be inferred by the number of elements in the iterator, and wastes computing time to winapi calls.
This also helps improving performance while looping for objects through the linked list of
Transform
s in a Unity scene, a very cpu intensive process.