using System.Collections.Generic; namespace YKMoon { public static class StackPool { // Object pool to avoid allocations. private static readonly ObjectPool> pool = new ObjectPool>(null, q => q.Clear()); public static Stack Get() { return pool.Get(); } public static void Release(Stack toRelease) { pool.Release(toRelease); } } }