Improving saver registration performance

Announcements, support questions, and discussion for Save System for Opsive Character Controllers.
Post Reply
szczepan
Posts: 5
Joined: Thu May 11, 2023 1:12 pm

Improving saver registration performance

Post by szczepan »

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.
Attachments
SaveSystem.zip
(6.61 KiB) Downloaded 438 times
User avatar
Tony Li
Posts: 22102
Joined: Thu Jul 18, 2013 1:27 pm

Re: Improving saver registration performance

Post by Tony Li »

Hi,

That sounds like a good optimization. I'll get it into the next release. Thanks for the suggestion!
Post Reply