From 6fb27577397056e76ac64be9b974b312a6be8ef3 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 23 Nov 2021 14:58:18 +0900 Subject: [PATCH] Remove usage of `Nuget.Packaging` extension methods for `IList.AddRange` --- osu.Game/Extensions/CollectionExtensions.cs | 22 ++++++++++++++++++++ osu.Game/Stores/BeatmapImporter.cs | 1 - osu.Game/Stores/RealmArchiveModelImporter.cs | 1 - 3 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 osu.Game/Extensions/CollectionExtensions.cs diff --git a/osu.Game/Extensions/CollectionExtensions.cs b/osu.Game/Extensions/CollectionExtensions.cs new file mode 100644 index 0000000000..473dc4b8f4 --- /dev/null +++ b/osu.Game/Extensions/CollectionExtensions.cs @@ -0,0 +1,22 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System.Collections.Generic; + +namespace osu.Game.Extensions +{ + public static class CollectionExtensions + { + public static void AddRange(this ICollection collection, IEnumerable items) + { + // List has a potentially more optimal path to adding a range. + if (collection is List list) + list.AddRange(items); + else + { + foreach (T obj in items) + collection.Add(obj); + } + } + } +} diff --git a/osu.Game/Stores/BeatmapImporter.cs b/osu.Game/Stores/BeatmapImporter.cs index dad2b29dd0..32f0cd3d7a 100644 --- a/osu.Game/Stores/BeatmapImporter.cs +++ b/osu.Game/Stores/BeatmapImporter.cs @@ -7,7 +7,6 @@ using System.IO; using System.Linq; using System.Threading; using System.Threading.Tasks; -using NuGet.Packaging; using osu.Framework.Audio.Track; using osu.Framework.Extensions; using osu.Framework.Extensions.IEnumerableExtensions; diff --git a/osu.Game/Stores/RealmArchiveModelImporter.cs b/osu.Game/Stores/RealmArchiveModelImporter.cs index 5b8c73b218..6370d4ebe4 100644 --- a/osu.Game/Stores/RealmArchiveModelImporter.cs +++ b/osu.Game/Stores/RealmArchiveModelImporter.cs @@ -8,7 +8,6 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; using Humanizer; -using NuGet.Packaging; using osu.Framework.Extensions; using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Logging;