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