Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into improve_mutation_of…
Browse files Browse the repository at this point in the history
…_directives
  • Loading branch information
dupdob committed Nov 22, 2024
2 parents da24233 + f7c0a71 commit 4102df8
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/Stryker.Core/Stryker.Core/Initialisation/InputFileResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -542,20 +542,20 @@ private static StringBuilder BuildReferenceChoice(IEnumerable<string> projectRef

private sealed class DynamicEnumerableQueue<T>
{
private readonly Queue<T> _queue;
private readonly HashSet<T> _cache;
private readonly ConcurrentQueue<T> _queue;
private readonly ConcurrentDictionary<T, bool> _cache;

public DynamicEnumerableQueue(IEnumerable<T> init)
{
_cache = [.. init];
_queue = new Queue<T>(_cache);
_cache = new(init.ToDictionary(x => x, x => true));
_queue = new (_cache.Keys);
}

public bool Empty => _queue.Count == 0;
public bool Empty => _queue.IsEmpty;

public void Add(T entry)
{
if (!_cache.Add(entry))
if (!_cache.TryAdd(entry, true))
{
return;
}
Expand All @@ -566,7 +566,10 @@ public IEnumerable<T> Consume()
{
while (_queue.Count > 0)
{
yield return _queue.Dequeue();
if (_queue.TryDequeue(out var entry))
{
yield return entry;
}
}
}
}
Expand Down

0 comments on commit 4102df8

Please sign in to comment.