diff options
| author | JP Dillingham <jp@dillingham.me> | 2024-04-27 18:42:05 -0500 |
|---|---|---|
| committer | JP Dillingham <jp@dillingham.me> | 2024-04-27 18:42:05 -0500 |
| commit | 2460cf84334f77be9515c1674a3d710a34479bc9 (patch) | |
| tree | 20a0dfa88eca9e6e144770ff439d7c74c8157941 /src | |
| parent | 163ac3ddcf38a568ed34679a76760c3e923ef9be (diff) | |
| download | slskd-2460cf84334f77be9515c1674a3d710a34479bc9.tar.gz | |
deduplicate entries
Diffstat (limited to 'src')
| -rw-r--r-- | src/slskd/Core/Blacklist.cs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/slskd/Core/Blacklist.cs b/src/slskd/Core/Blacklist.cs index 4a47b8a8..7b1a46c6 100644 --- a/src/slskd/Core/Blacklist.cs +++ b/src/slskd/Core/Blacklist.cs @@ -268,13 +268,17 @@ public class Blacklist } // copy working dictionary to a temporary cache to: - // * convert List<> to array to increase access speed + // * deduplicate entries // * sort arrays by first IP to enable binary search (future?) + // * convert List<> to array to increase access speed var tempCache = new ConcurrentDictionary<int, (uint First, uint Last)[]>(); foreach (var key in dict.Keys) { - tempCache[key] = dict[key].OrderBy(x => x.First).ToArray(); + tempCache[key] = dict[key] + .Distinct() + .OrderBy(x => x.First) + .ToArray(); } // swap the temporary cache for the "real" cache, enabling a bumpless update |
