LiveSplit / asr

Helper crate to write auto splitters for LiveSplit One's auto splitting runtime.
https://livesplit.org/asr/asr
Apache License 2.0
10 stars 10 forks source link

[Unity] Improved performance of the `root_game_objects` function #62

Closed Jujstme closed 11 months ago

Jujstme commented 1 year ago

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.

Jujstme commented 11 months ago

Closing this because I will make a new PR with a lot more changes