فهرست منبع

优化LSUpdater

tanghai 1 سال پیش
والد
کامیت
2e026de115

+ 2 - 6
Unity/Assets/Scripts/Model/Share/LockStep/LSUpdater.cs

@@ -5,8 +5,8 @@ namespace ET
 {
     public class LSUpdater: Object
     {
-        private List<long> updateIds = new();
-        private List<long> newUpdateIds = new();
+        private readonly NativeCollection.SortedSet<long> updateIds = new();
+        private readonly NativeCollection.SortedSet<long> newUpdateIds = new();
 
         private readonly Dictionary<long, EntityRef<LSEntity>> lsEntities = new();
 
@@ -18,7 +18,6 @@ namespace ET
                 {
                     this.updateIds.Add(id);
                 }
-                this.updateIds.Sort();
                 this.newUpdateIds.Clear();
             }
 
@@ -30,11 +29,8 @@ namespace ET
                     this.lsEntities.Remove(id);
                     continue;
                 }
-                this.newUpdateIds.Add(id);
                 LSEntitySystemSingleton.Instance.LSUpdate(entity);
             }
-            this.updateIds.Clear();
-            ObjectHelper.Swap(ref this.updateIds, ref this.newUpdateIds);
         }
         
         public void Add(LSEntity entity)

+ 2 - 0
Unity/Assets/Scripts/Model/Share/Module/Message/LogMsg.cs

@@ -1,4 +1,5 @@
 using System.Collections.Generic;
+using System.Diagnostics;
 
 namespace ET
 {
@@ -16,6 +17,7 @@ namespace ET
         {
         }
 
+        [Conditional("DEBUG")]
         public void Debug(Fiber fiber, object msg)
         {
             ushort opcode = OpcodeType.Instance.GetOpcode(msg.GetType());