perf!: improved sorted behaviour collector by using binary insertion to reduce performance impact

This commit is contained in:
2025-05-31 12:00:32 +03:00
parent 61e2761580
commit 1acc8bdb8f
7 changed files with 103 additions and 19 deletions

View File

@@ -56,12 +56,13 @@ public class ActiveBehaviourCollector<T> : IBehaviourCollector<T> where T : clas
OnBehaviourStateChanged(tBehaviour, new(!tBehaviour.IsActive));
}
protected virtual void AddBehaviour(T behaviour) => activeBehaviours.Add(behaviour);
private void OnBehaviourStateChanged(IActive sender, IActive.ActiveChangedArguments args)
{
T behaviour = monitoringActiveToBehaviour[sender];
if (sender.IsActive)
{
activeBehaviours.Add(behaviour);
AddBehaviour(behaviour);
OnBehaviourAdd(behaviour);
OnCollected?.Invoke(this, new(behaviour));
}