perf(config): clone only temp tabs in SaveConfig snapshot/restore (F2.2)

The pre-serialization snapshot used to clone the entire Config.Tabs
list, then Clear/AddRange the snapshot back. With a typical config of
~30 user-defined tabs plus up to 15 session-only temp tabs, that's a
45-item clone on every save. The persistent tabs never leave the list
during this routine, so cloning only the temp subset is functionally
identical and keeps the allocation proportional to AutoTellTabsLimit.
This commit is contained in:
2026-05-12 19:35:17 +02:00
parent 2684c31f10
commit ae1436b103
+9 -7
View File
@@ -637,18 +637,20 @@ public sealed class Plugin : IAsyncDalamudPlugin
internal void SaveConfig() internal void SaveConfig()
{ {
// Strip session-only Auto-Tell-Tabs before serialization; restore after. // Session-only Auto-Tell-Tabs aren't persisted, so they move aside
var snapshot = Config.Tabs.ToList(); // before serialization and re-attach after. Cloning only the temp
// subset keeps the allocation proportional to AutoTellTabsLimit
// (<=15) instead of the full tab list.
var tempTabs = Config.Tabs.Where(t => t.IsTempTab).ToList();
Config.Tabs.RemoveAll(t => t.IsTempTab); Config.Tabs.RemoveAll(t => t.IsTempTab);
Interface.SavePluginConfig(Config); Interface.SavePluginConfig(Config);
Config.Tabs.Clear(); Config.Tabs.AddRange(tempTabs);
Config.Tabs.AddRange(snapshot);
// F2.1: snapshot-restore preserves IsTempTab tabs but the mid-step // F2.1: the mid-step RemoveAll bypasses AutoTellTabsService, so
// RemoveAll bypasses AutoTellTabsService, so re-peg the counter. // re-peg the counter. Null-conditional because SaveConfig can fire
// Null-conditional because SaveConfig can fire before Phase-2 init. // before Phase-2 init.
AutoTellTabsService?.ResyncTempTabCounter(); AutoTellTabsService?.ResyncTempTabCounter();
} }