mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-16 13:15:07 +00:00
Potential optimization in ScrollQueue
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using ICD.Common.Properties;
|
using ICD.Common.Properties;
|
||||||
|
using ICD.Common.Utils.Extensions;
|
||||||
|
|
||||||
namespace ICD.Common.Utils.Collections
|
namespace ICD.Common.Utils.Collections
|
||||||
{
|
{
|
||||||
@@ -86,9 +86,18 @@ namespace ICD.Common.Utils.Collections
|
|||||||
[PublicAPI]
|
[PublicAPI]
|
||||||
public void Enqueue(TContents item)
|
public void Enqueue(TContents item)
|
||||||
{
|
{
|
||||||
m_CollectionLock.Execute(() => m_Collection.AddLast(item));
|
m_CollectionLock.Enter();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
m_Collection.AddLast(item);
|
||||||
Trim();
|
Trim();
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
m_CollectionLock.Leave();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Removes the oldest item from the queue.
|
/// Removes the oldest item from the queue.
|
||||||
@@ -132,7 +141,7 @@ namespace ICD.Common.Utils.Collections
|
|||||||
|
|
||||||
public IEnumerator<TContents> GetEnumerator()
|
public IEnumerator<TContents> GetEnumerator()
|
||||||
{
|
{
|
||||||
return m_CollectionLock.Execute(() => m_Collection.ToList().GetEnumerator());
|
return m_CollectionLock.Execute(() => m_Collection.ToList(Count).GetEnumerator());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICollection.CopyTo(Array myArr, int index)
|
void ICollection.CopyTo(Array myArr, int index)
|
||||||
|
|||||||
Reference in New Issue
Block a user