mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-23 09:20:08 +00:00
优化性能,优化折线图和柱状图的大数据绘制,重构代码
This commit is contained in:
@@ -6,13 +6,24 @@
|
||||
/******************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
internal static class ListPool<T>
|
||||
{
|
||||
private static readonly ObjectPool<List<T>> s_ListPool = new ObjectPool<List<T>>(null, Clear);
|
||||
static void Clear(List<T> l) { l.Clear(); }
|
||||
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();
|
||||
}
|
||||
|
||||
public static List<T> Get()
|
||||
{
|
||||
@@ -23,5 +34,10 @@ namespace XCharts
|
||||
{
|
||||
s_ListPool.Release(toRelease);
|
||||
}
|
||||
|
||||
public static void ClearAll()
|
||||
{
|
||||
s_ListPool.ClearAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user