Skip to content

Commit

Permalink
Kill mutants
Browse files Browse the repository at this point in the history
  • Loading branch information
martintmk committed Mar 31, 2023
1 parent 2a533ce commit 983cee0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/Polly.Core/Strategy/Predicate.Handler.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Collections.Generic;
using Polly.Strategy;

namespace Polly.Retry;
Expand Down Expand Up @@ -84,7 +85,7 @@ private sealed class ManyHandler : Handler
{
private readonly Dictionary<Type, SingleHandler> _predicates;

public ManyHandler(Dictionary<Type, List<object>> predicates)
public ManyHandler(IEnumerable<KeyValuePair<Type, List<object>>> predicates)
=> _predicates = predicates.ToDictionary(v => v.Key, v => new SingleHandler(v.Key, v.Value));

public override async ValueTask<bool> ShouldHandle<TResult>(Outcome<TResult> outcome, TArgs args)
Expand Down
8 changes: 5 additions & 3 deletions src/Polly.Core/Strategy/Predicate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,13 @@ public TPredicate AddOutcome<TResult>(Func<Outcome<TResult>, TArgs, ValueTask<bo
/// <returns>Handler instance or null of no predicates are registered.</returns>
protected internal Handler? CreateHandler()
{
return _predicates.Count switch
var pairs = _predicates.ToArray();

return pairs.Length switch
{
0 => null,
1 => new SingleHandler(_predicates.Keys.Single(), _predicates.Values.Single()),
_ => new ManyHandler(_predicates)
1 => new SingleHandler(pairs[0].Key, pairs[0].Value),
_ => new ManyHandler(pairs)
};
}

Expand Down

0 comments on commit 983cee0

Please sign in to comment.