resizeable message store
parent
5bc0294158
commit
e4d4df9fdd
|
@ -14,7 +14,7 @@ namespace Encompass
|
||||||
// messages are placed in a contiguous region
|
// messages are placed in a contiguous region
|
||||||
// so we can return the collection as a Span
|
// so we can return the collection as a Span
|
||||||
private int _nextIndex = 0;
|
private int _nextIndex = 0;
|
||||||
private readonly TMessage[] _store = new TMessage[128];
|
private TMessage[] _store = new TMessage[128];
|
||||||
private readonly List<(TMessage, double)> _delayedStore = new List<(TMessage, double)>(128);
|
private readonly List<(TMessage, double)> _delayedStore = new List<(TMessage, double)>(128);
|
||||||
private readonly List<(TMessage, double)> _delayedStoreIgnoringTimeDilation = new List<(TMessage, double)>(128);
|
private readonly List<(TMessage, double)> _delayedStoreIgnoringTimeDilation = new List<(TMessage, double)>(128);
|
||||||
private readonly Dictionary<int, List<int>> _entityToIndices = new Dictionary<int, List<int>>();
|
private readonly Dictionary<int, List<int>> _entityToIndices = new Dictionary<int, List<int>>();
|
||||||
|
@ -59,6 +59,10 @@ namespace Encompass
|
||||||
public void Add(in TMessage message)
|
public void Add(in TMessage message)
|
||||||
{
|
{
|
||||||
var index = _nextIndex++;
|
var index = _nextIndex++;
|
||||||
|
if (index >= _store.Length)
|
||||||
|
{
|
||||||
|
Array.Resize(ref _store, _store.Length * 2);
|
||||||
|
}
|
||||||
_store[index] = message;
|
_store[index] = message;
|
||||||
if (message is IHasEntity entityMessage)
|
if (message is IHasEntity entityMessage)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue