Improving saver registration performance
Posted: Fri May 12, 2023 9:21 pm
I noticed that on a scene with large number of savers, performance can drop significantly when adding additional savers - in my case when a new object is spawned. This is caused by calling Contains method on a List here:
public static void RegisterSaver(Saver saver)
{
if (saver == null || m_savers.Contains(saver)) return;
m_savers.Add(saver);
}
This could be improved a lot if HashSet was used instead of a List. I attached rough implementation for you evaluation.
public static void RegisterSaver(Saver saver)
{
if (saver == null || m_savers.Contains(saver)) return;
m_savers.Add(saver);
}
This could be improved a lot if HashSet was used instead of a List. I attached rough implementation for you evaluation.