From 33e59ca98efbbe82855d32692815a761b6ec02ce Mon Sep 17 00:00:00 2001 From: Robert Dailey Date: Sun, 25 Aug 2024 08:56:02 -0500 Subject: [PATCH] test: Optimize StubAutofacIndex.AddRange() --- tests/Recyclarr.TestLibrary/Autofac/StubAutofacIndex.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/Recyclarr.TestLibrary/Autofac/StubAutofacIndex.cs b/tests/Recyclarr.TestLibrary/Autofac/StubAutofacIndex.cs index b9b11855..e6ee0344 100644 --- a/tests/Recyclarr.TestLibrary/Autofac/StubAutofacIndex.cs +++ b/tests/Recyclarr.TestLibrary/Autofac/StubAutofacIndex.cs @@ -3,10 +3,11 @@ using Autofac.Features.Indexed; namespace Recyclarr.TestLibrary.Autofac; +[UsedImplicitly] public class StubAutofacIndex : IIndex where TKey : notnull { - private Dictionary _values = new(); + private readonly Dictionary _values = new(); public StubAutofacIndex() { @@ -24,7 +25,10 @@ public class StubAutofacIndex : IIndex public void AddRange(IEnumerable<(TKey, TValue)> pairs) { - _values = _values.Union(pairs.ToDictionary(x => x.Item1, x => x.Item2)).ToDictionary(); + foreach (var (key, value) in pairs) + { + _values[key] = value; + } } public bool TryGetValue(TKey key, [UnscopedRef] out TValue value)