branchrust_reboot/main/findprefab_optimscancel
2 Commits over 0 Days - Infinitycph!
Optimized entities with flag toggles spawning: EntityFlag_Toggle now bakes its listeners at prefab preprocessing and calls them directly instead of invoking its UnityEvent
The first UnityEvent invoke on every new instance looked its listeners up by reflection.
Rough profiling from the editor, loading in a mix of 248 entities (io, locks, doors and some random deployables)
EntityFlag.DoUpdate
26ms -> 2ms total
~100us -> ~9us per entity
~940 KB -> ~231 KB total
Optimized prefab lookups by path, we now cache exact spelling hits. Makes each FindPrefab ~7x faster on repeat calls
(was around 6us per call in builds, up to 0.5ms in frames that spawn a lot when entering network range of a base)
We could make prefab paths case sensitive instead, but I'm not gonna change the million callers and that could break plugins