From 488b4a4a84ba913acb4812cfeba1ce64e2888ef8 Mon Sep 17 00:00:00 2001 From: sebas77 Date: Mon, 25 Dec 2017 00:12:10 +0000 Subject: [PATCH] fix bug that would have called remove twice when engine profiler was used remove redundant functions --- ECS/EnginesRoot.cs | 15 ++------------- ECS/Profiler/EngineProfiler.cs | 7 +++---- 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/ECS/EnginesRoot.cs b/ECS/EnginesRoot.cs index 20fa828..404b187 100644 --- a/ECS/EnginesRoot.cs +++ b/ECS/EnginesRoot.cs @@ -376,7 +376,7 @@ namespace Svelto.ECS for (int j = 0; j < enginesForNode.Count; j++) { #if ENGINE_PROFILER_ENABLED && UNITY_EDITOR - EngineProfiler.MonitorAddDuration(AddNodeToEngine, enginesForNode[j] as INodeEngine, node); + EngineProfiler.MonitorAddDuration(enginesForNode[j] as INodeEngine, node); #else (enginesForNode[j] as INodeEngine).Add(node); #endif @@ -415,7 +415,7 @@ namespace Svelto.ECS for (int j = 0; j < enginesForNode.Count; j++) { #if ENGINE_PROFILER_ENABLED && UNITY_EDITOR - EngineProfiler.MonitorRemoveDuration(RemoveNodeFromEngine, (enginesForNode[j] as INodeEngine), node); + EngineProfiler.MonitorRemoveDuration((enginesForNode[j] as INodeEngine), node); #else (enginesForNode[j] as INodeEngine).Remove(node); #endif @@ -448,17 +448,6 @@ namespace Svelto.ECS } } } -#if ENGINE_PROFILER_ENABLED && UNITY_EDITOR - void AddNodeToEngine(IEngine engine, INode node) - { - (engine as INodeEngine).Add(node); - } - - void RemoveNodeFromEngine(IEngine engine, INode node) - { - (engine as INodeEngine).Remove(node); - } -#endif void InternalDisable(FasterList nodes) { diff --git a/ECS/Profiler/EngineProfiler.cs b/ECS/Profiler/EngineProfiler.cs index 0612925..2b07067 100644 --- a/ECS/Profiler/EngineProfiler.cs +++ b/ECS/Profiler/EngineProfiler.cs @@ -12,28 +12,27 @@ namespace Svelto.ECS.Profiler { static readonly Stopwatch _stopwatch = new Stopwatch(); - public static void MonitorAddDuration(Action addingFunc, INodeEngine engine, INode node) + public static void MonitorAddDuration(INodeEngine engine, INode node) { EngineInfo info; if (engineInfos.TryGetValue(engine.GetType(), out info)) { _stopwatch.Reset(); _stopwatch.Start(); - addingFunc(engine, node); + engine.Add(node); _stopwatch.Stop(); info.AddAddDuration(_stopwatch.Elapsed.TotalMilliseconds); } } - public static void MonitorRemoveDuration(Action removeFunc, INodeEngine engine, INode node) + public static void MonitorRemoveDuration(INodeEngine engine, INode node) { EngineInfo info; if (engineInfos.TryGetValue(engine.GetType(), out info)) { _stopwatch.Reset(); _stopwatch.Start(); - removeFunc(engine, node); engine.Remove(node); _stopwatch.Stop();