2019-10-22 04:09:04 +08:00
|
|
|
/******************************************/
|
|
|
|
|
/* */
|
|
|
|
|
/* Copyright (c) 2018 monitor1394 */
|
|
|
|
|
/* https://github.com/monitor1394 */
|
|
|
|
|
/* */
|
|
|
|
|
/******************************************/
|
|
|
|
|
|
2019-08-15 21:44:30 +08:00
|
|
|
using System.Collections.Generic;
|
2020-05-13 09:54:40 +08:00
|
|
|
using UnityEngine;
|
2019-08-15 21:44:30 +08:00
|
|
|
|
|
|
|
|
namespace XCharts
|
|
|
|
|
{
|
|
|
|
|
internal static class ListPool<T>
|
|
|
|
|
{
|
2020-05-13 09:54:40 +08:00
|
|
|
private static readonly ObjectPool<List<T>> s_ListPool = new ObjectPool<List<T>>(OnGet, OnClear);
|
|
|
|
|
static void OnGet(List<T> l)
|
|
|
|
|
{
|
|
|
|
|
if (l.Capacity < 50)
|
|
|
|
|
{
|
|
|
|
|
l.Capacity = 50;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
static void OnClear(List<T> l)
|
|
|
|
|
{
|
|
|
|
|
l.Clear();
|
|
|
|
|
}
|
2019-08-15 21:44:30 +08:00
|
|
|
|
|
|
|
|
public static List<T> Get()
|
|
|
|
|
{
|
|
|
|
|
return s_ListPool.Get();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void Release(List<T> toRelease)
|
|
|
|
|
{
|
|
|
|
|
s_ListPool.Release(toRelease);
|
|
|
|
|
}
|
2020-05-13 09:54:40 +08:00
|
|
|
|
|
|
|
|
public static void ClearAll()
|
|
|
|
|
{
|
|
|
|
|
s_ListPool.ClearAll();
|
|
|
|
|
}
|
2019-08-15 21:44:30 +08:00
|
|
|
}
|
|
|
|
|
}
|