mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-06 08:16:19 +00:00
perf: Micro-optimization
This commit is contained in:
@@ -84,18 +84,15 @@ namespace ICD.Common.Utils
|
||||
/// <returns></returns>
|
||||
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;
|
||||
|
||||
if (!map.ContainsKey(node))
|
||||
IEnumerable<T> adjacent;
|
||||
if (!map.TryGetValue(node, out adjacent))
|
||||
yield break;
|
||||
|
||||
visited.Add(node);
|
||||
|
||||
yield return node;
|
||||
|
||||
IEnumerable<T> adjacent = map.GetDefault(node, Enumerable.Empty<T>());
|
||||
|
||||
foreach (T item in adjacent.SelectMany(a => GetClique(map, visited, a)))
|
||||
yield return item;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user