NLDClient-yudde/ProjectNLD/Assets/Code/Scripts/Framework/Event/EventManager.Opt.cs

34 lines
915 B
C#
Raw Normal View History

2023-08-22 19:08:45 +08:00
using System;
using System.Collections.Generic;
namespace Framework
{
public partial class EventManager
{
private readonly List<Delegate> _tempExecuteList = new List<Delegate>(16);
private Stack<List<Delegate>> _tempExecutePool = new Stack<List<Delegate>>();
private Stack<EventName> _eventSendingStack = new Stack<EventName>(MAX_EVENT_STACK + 1);
2023-08-22 19:08:45 +08:00
private List<Delegate> GetTempExecuteList()
{
if (_tempExecutePool.TryPop(out var list))
{
return list;
}
return new List<Delegate>(8);
}
private void ReCycleTempExecuteList(List<Delegate> list)
{
if (_tempExecutePool.Count < MAX_EVENT_STACK)
{
list.Clear();
_tempExecutePool.Push(list);
}
}
}
}