diff options
| author | Mark Monteiro <marknr.monteiro@protonmail.com> | 2020-03-03 18:18:00 +0100 |
|---|---|---|
| committer | Mark Monteiro <marknr.monteiro@protonmail.com> | 2020-03-03 18:18:00 +0100 |
| commit | 3cb98fba553024a1a47d5d4179351184ce76ccf7 (patch) | |
| tree | 123e49d9260881c0c1779ce8c4e72335b7426c03 | |
| parent | 6438771212cd7e8b46a71d5b1a78d6e6c5d42f69 (diff) | |
Use ToList() instead of ToArray() on sequences of unknown size
| -rw-r--r-- | Emby.Server.Implementations/Playlists/PlaylistManager.cs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/Emby.Server.Implementations/Playlists/PlaylistManager.cs b/Emby.Server.Implementations/Playlists/PlaylistManager.cs index 42d14a9e5..5a6ecf5c1 100644 --- a/Emby.Server.Implementations/Playlists/PlaylistManager.cs +++ b/Emby.Server.Implementations/Playlists/PlaylistManager.cs @@ -196,7 +196,7 @@ namespace Emby.Server.Implementations.Playlists // Retrieve all the items to be added to the playlist var items = GetPlaylistItems(itemIds, playlist.MediaType, user, options) .Where(i => i.SupportsAddingToPlaylist) - .ToArray(); + .ToList(); // Remove duplicates from the new items to be added var existingIds = playlist.LinkedChildren.Select(c => c.ItemId).ToHashSet(); @@ -205,23 +205,23 @@ namespace Emby.Server.Implementations.Playlists .GroupBy(i => i.Id) .Select(group => group.First()) .Select(i => LinkedChild.Create(i)) - .ToArray(); + .ToList(); // Log duplicates that have been ignored, if any - int numDuplicates = items.Length - uniqueItems.Length; + int numDuplicates = items.Count - uniqueItems.Count; if (numDuplicates > 0) { _logger.LogWarning("Ignored adding {DuplicateCount} duplicate items to playlist {PlaylistName}.", numDuplicates, playlist.Name); } // Do nothing else if there are no items to add to the playlist - if (uniqueItems.Length == 0) + if (uniqueItems.Count == 0) { return; } // Create a new array with the updated playlist items - var newLinkedChildren = new LinkedChild[playlist.LinkedChildren.Length + uniqueItems.Length]; + var newLinkedChildren = new LinkedChild[playlist.LinkedChildren.Length + uniqueItems.Count]; playlist.LinkedChildren.CopyTo(newLinkedChildren, 0); uniqueItems.CopyTo(newLinkedChildren, playlist.LinkedChildren.Length); |
