ListPool.cs 525 B

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