Merge pull request #435 from dotnet-campus/t/lindexi/Perfomance-deque

Improve Deque initialization performance
This commit is contained in:
NaBian authored and GitHub committed 2020-07-11 19:12:06 +08:00
commit 42a7d374b6
1 file changed
+2 -11
@@ -66,18 +66,9 @@ namespace HandyControl.Tools
public Deque(IEnumerable<T> backCollection, IEnumerable<T> frontCollection)
{
if (backCollection == null && frontCollection == null) throw new ArgumentException("Collections cannot both be null");
_front = new List<T>();
_back = new List<T>();
if (backCollection != null)
{
foreach (var item in backCollection) _back.Add(item);
}
if (frontCollection != null)
{
foreach (var item in frontCollection) _front.Add(item);
}
_front = frontCollection != null ? new List<T>(frontCollection) : new List<T>();
_back = backCollection != null ? new List<T>(backCollection) : new List<T>();
}
public void AddFirst(T item)