mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-04-12 12:07:05 +00:00
perf: Micro-optimization
This commit is contained in:
parent
74c59bd7f3
commit
aeb2a5d91e
1 changed files with 3 additions and 6 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue