using System.Collections.Generic; using Gum.Pooling.Collections; #if GUM_DEBUG using Gum.Pooling.Diagnostics; #endif namespace Gum.Pooling { internal sealed class DictionaryPool { private readonly Stack> _pool = new Stack>(); public static readonly DictionaryPool Shared = new DictionaryPool(); public void Put(PooledDictionary dictionary) { if (!_pool.Contains(dictionary)) { _pool.Push(dictionary); #if GUM_DEBUG PoolMonitor.UnreleasedPooledDictionaries.Remove(dictionary); #endif } } public PooledDictionary Get() { PooledDictionary pooledDictionary = _pool.Count > 0 ? _pool.Pop() : new PooledDictionary(); #if GUM_DEBUG PoolMonitor.UnreleasedPooledDictionaries.Add(pooledDictionary, new System.Diagnostics.StackTrace().ToString()); #endif return pooledDictionary; } } }