Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ _pruneCachedSwitches()

static void System.Diagnostics.Switch._pruneCachedSwitches ( )
inlinestaticprivateinherited

Definition at line 137 of file Switch.cs.

138 {
140 {
141 if (s_LastCollectionCount == GC.CollectionCount(2))
142 {
143 return;
144 }
146 for (int i = 0; i < s_switches.Count; i++)
147 {
148 if (s_switches[i].TryGetTarget(out var _))
149 {
150 list.Add(s_switches[i]);
151 }
152 }
153 if (list.Count < s_switches.Count)
154 {
155 s_switches.Clear();
156 s_switches.AddRange(list);
157 s_switches.TrimExcess();
158 }
159 s_LastCollectionCount = GC.CollectionCount(2);
160 }
161 }
void Add(TKey key, TValue value)
static int s_LastCollectionCount
Definition Switch.cs:28
static readonly List< WeakReference< Switch > > s_switches
Definition Switch.cs:26

References System.Collections.Generic.Dictionary< TKey, TValue >.Add(), System.GC.CollectionCount(), System.list, System.Diagnostics.Switch.s_LastCollectionCount, and System.Diagnostics.Switch.s_switches.

Referenced by System.Diagnostics.Switch.Switch(), and System.Diagnostics.Switch.RefreshAll().