mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-15 12:45:01 +00:00
perf: Micro-optimization
This commit is contained in:
@@ -84,18 +84,15 @@ namespace ICD.Common.Utils
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private static IEnumerable<T> GetCliqueIterator<T>(IDictionary<T, IEnumerable<T>> map, IcdHashSet<T> visited, T node)
|
private static IEnumerable<T> GetCliqueIterator<T>(IDictionary<T, IEnumerable<T>> map, IcdHashSet<T> visited, T node)
|
||||||
{
|
{
|
||||||
if (visited.Contains(node))
|
if (!visited.Add(node))
|
||||||
yield break;
|
yield break;
|
||||||
|
|
||||||
if (!map.ContainsKey(node))
|
IEnumerable<T> adjacent;
|
||||||
|
if (!map.TryGetValue(node, out adjacent))
|
||||||
yield break;
|
yield break;
|
||||||
|
|
||||||
visited.Add(node);
|
|
||||||
|
|
||||||
yield return node;
|
yield return node;
|
||||||
|
|
||||||
IEnumerable<T> adjacent = map.GetDefault(node, Enumerable.Empty<T>());
|
|
||||||
|
|
||||||
foreach (T item in adjacent.SelectMany(a => GetClique(map, visited, a)))
|
foreach (T item in adjacent.SelectMany(a => GetClique(map, visited, a)))
|
||||||
yield return item;
|
yield return item;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user