mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-13 19:55:02 +00:00
perf: Potential performance improvement when comparing enumerables
This commit is contained in:
@@ -227,6 +227,12 @@ namespace ICD.Common.Utils.Extensions
|
||||
if (comparer == null)
|
||||
throw new ArgumentNullException("comparer");
|
||||
|
||||
// Simple count check
|
||||
ICollection<T> a = extends as ICollection<T>;
|
||||
ICollection<T> b = other as ICollection<T>;
|
||||
if (a != null && b != null && a.Count != b.Count)
|
||||
return false;
|
||||
|
||||
using (IEnumerator<T> firstPos = extends.GetEnumerator())
|
||||
{
|
||||
using (IEnumerator<T> secondPos = other.GetEnumerator())
|
||||
@@ -285,6 +291,12 @@ namespace ICD.Common.Utils.Extensions
|
||||
if (comparer == null)
|
||||
throw new ArgumentNullException("comparer");
|
||||
|
||||
// Simple count check
|
||||
ICollection<T> a = extends as ICollection<T>;
|
||||
ICollection<T> b = other as ICollection<T>;
|
||||
if (a != null && b != null && a.Count != b.Count)
|
||||
return false;
|
||||
|
||||
Dictionary<T, int> count = new Dictionary<T, int>(comparer);
|
||||
|
||||
foreach (T item in extends)
|
||||
|
||||
Reference in New Issue
Block a user