Açıklama Yok
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ListPool.cs 759B

1234567891011121314151617181920212223242526272829303132333435
  1. using System.Collections.Generic;
  2. namespace XCharts.Runtime
  3. {
  4. internal static class ListPool<T>
  5. {
  6. private static readonly ObjectPool<List<T>> s_ListPool = new ObjectPool<List<T>>(OnGet, OnClear);
  7. static void OnGet(List<T> l)
  8. {
  9. if (l.Capacity < 50)
  10. {
  11. l.Capacity = 50;
  12. }
  13. }
  14. static void OnClear(List<T> l)
  15. {
  16. l.Clear();
  17. }
  18. public static List<T> Get()
  19. {
  20. return s_ListPool.Get();
  21. }
  22. public static void Release(List<T> toRelease)
  23. {
  24. s_ListPool.Release(toRelease);
  25. }
  26. public static void ClearAll()
  27. {
  28. s_ListPool.ClearAll();
  29. }
  30. }
  31. }