- Изменено
When caching stops being helpful?
Of course using FindSlots every frame is much more expensive than caching a slot in the beginning.
However, what if you have a few hundreds slots which are accessed a few times per scene, definitely not every frame? Is caching still preferable, or keeping that many slots during the whole scene is a waste of memory?
Keeping a reference to a slot takes up very little memory, so little you should not worry about it. It is just a reference, not a copy.
Using Skeleton findSlot
likely won't make your app too slow, it is just a bit wasteful for the CPU to compare the names of many slots. Another option is to put all the slots in a hashmap (dictionary in C#) so you can quickly find one by name rather than maintaining many fields.
Making a dictionary is a great idea, thanks!