mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-04-12 12:07:05 +00:00
Potential optimization in ScrollQueue
This commit is contained in:
parent
96fc6787a5
commit
3eb4fa9e92
1 changed files with 13 additions and 4 deletions
|
|
@ -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,8 +86,17 @@ 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();
|
||||||
Trim();
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
m_Collection.AddLast(item);
|
||||||
|
Trim();
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
m_CollectionLock.Leave();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -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)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue