From 99a11d2bb19d74f6cc8584ac16838062af4fb301 Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期五, 03 四月 2026 11:24:07 +0800
Subject: [PATCH] webgl 优化

---
 Main/Component/UI/Effect/TimeMgr.cs |   17 ++++++++++-------
 1 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/Main/Component/UI/Effect/TimeMgr.cs b/Main/Component/UI/Effect/TimeMgr.cs
index e1be090..eb3599e 100644
--- a/Main/Component/UI/Effect/TimeMgr.cs
+++ b/Main/Component/UI/Effect/TimeMgr.cs
@@ -59,7 +59,7 @@
         {
             Debug.Log(e.StackTrace);
         }
-        for (int i = 0; i < syntonyList.Count; i++)
+        for (int i = syntonyList.Count - 1; i >= 0; i--)
         {
             if ((TimeUtility.ServerNow - syntonyList[i].endTime).TotalSeconds > 0)
             {
@@ -68,21 +68,24 @@
                     syntonyList[i].callback();
                 }
                 var _type = syntonyList[i].type;
-                syntonyList.RemoveAt(i);
+                // Swap-remove閬垮厤O(n)绉讳綅
+                int last = syntonyList.Count - 1;
+                if (i < last)
+                    syntonyList[i] = syntonyList[last];
+                syntonyList.RemoveAt(last);
                 if (OnSyntonyEvent != null)
                 {
                     OnSyntonyEvent(_type);
                 }
-                i--;
             }
         }
         if (timeItems.Count > 0)
         {
-            timeItemList.RemoveRange(0, timeItemList.Count);
-            foreach (Component item in timeItems.Keys)
+            timeItemList.Clear();
+            foreach (var kv in timeItems)
             {
-                if (item == null) continue;
-                timeItemList.Add(timeItems[item]);
+                if (kv.Key == null) continue;
+                timeItemList.Add(kv.Value);
             }
             for (int i = 0; i < timeItemList.Count; i++)
             {

--
Gitblit v1.8.0