TMP_ListPool.cs 495 B

123456789101112131415161718192021
  1. using System.Collections.Generic;
  2. namespace TMPro
  3. {
  4. internal static class TMP_ListPool<T>
  5. {
  6. // Object pool to avoid allocations.
  7. private static readonly TMP_ObjectPool<List<T>> s_ListPool = new TMP_ObjectPool<List<T>>(null, l => l.Clear());
  8. public static List<T> Get()
  9. {
  10. return s_ListPool.Get();
  11. }
  12. public static void Release(List<T> toRelease)
  13. {
  14. s_ListPool.Release(toRelease);
  15. }
  16. }
  17. }