// dnlib: See LICENSE.txt for more info using System.Collections.Generic; using System.Threading; namespace dnlib.DotNet.Pdb.Portable { static class ListCache { static volatile List cachedList; public static List AllocList() => Interlocked.Exchange(ref cachedList, null) ?? new List(); public static void Free(ref List list) { list.Clear(); cachedList = list; } public static T[] FreeAndToArray(ref List list) { var res = list.ToArray(); Free(ref list); return res; } } }