From c6bf6e00de5906844396bee59e9e891b2903815e Mon Sep 17 00:00:00 2001 From: ignacio laborde Date: Tue, 4 Jan 2022 13:05:36 -0300 Subject: Remove unnecessary ToList usage --- Emby.Server.Implementations/Collections/CollectionManager.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'Emby.Server.Implementations/Collections') diff --git a/Emby.Server.Implementations/Collections/CollectionManager.cs b/Emby.Server.Implementations/Collections/CollectionManager.cs index 5fc2e39a7..1bbcbe2dd 100644 --- a/Emby.Server.Implementations/Collections/CollectionManager.cs +++ b/Emby.Server.Implementations/Collections/CollectionManager.cs @@ -210,7 +210,7 @@ namespace Emby.Server.Implementations.Collections var itemList = new List(); var linkedChildrenList = collection.GetLinkedChildren(); - var currentLinkedChildrenIds = linkedChildrenList.Select(i => i.Id).ToList(); + var currentLinkedChildrenIds = linkedChildrenList.Select(i => i.Id); foreach (var id in ids) { @@ -232,10 +232,7 @@ namespace Emby.Server.Implementations.Collections if (list.Count > 0) { - var newList = collection.LinkedChildren.ToList(); - newList.AddRange(list); - collection.LinkedChildren = newList.ToArray(); - + collection.LinkedChildren = collection.LinkedChildren.Concat(list).ToArray(); collection.UpdateRatingToItems(linkedChildrenList); await collection.UpdateToRepositoryAsync(ItemUpdateType.MetadataEdit, CancellationToken.None).ConfigureAwait(false); @@ -303,7 +300,7 @@ namespace Emby.Server.Implementations.Collections { var results = new Dictionary(); - var allBoxSets = GetCollections(user).ToList(); + var allBoxSets = GetCollections(user); foreach (var item in items) { -- cgit v1.2.3 From 5cd37686ac43c5595e63dfc47bfaf339f2be3271 Mon Sep 17 00:00:00 2001 From: ignacio laborde Date: Tue, 4 Jan 2022 13:57:19 -0300 Subject: address PR comments --- Emby.Naming/Video/VideoListResolver.cs | 2 +- Emby.Server.Implementations/Collections/CollectionManager.cs | 4 ++-- Emby.Server.Implementations/Library/LibraryManager.cs | 5 +++-- 3 files changed, 6 insertions(+), 5 deletions(-) (limited to 'Emby.Server.Implementations/Collections') diff --git a/Emby.Naming/Video/VideoListResolver.cs b/Emby.Naming/Video/VideoListResolver.cs index a4f1d4c78..11f82525f 100644 --- a/Emby.Naming/Video/VideoListResolver.cs +++ b/Emby.Naming/Video/VideoListResolver.cs @@ -29,7 +29,7 @@ namespace Emby.Naming.Video .Where(i => i.ExtraType == null) .Select(i => new FileSystemMetadata { FullName = i.Path, IsDirectory = i.IsDirectory }); - var stackResult = StackResolver.Resolve(nonExtras, namingOptions); + var stackResult = StackResolver.Resolve(nonExtras, namingOptions).ToList(); var remainingFiles = new List(); var standaloneMedia = new List(); diff --git a/Emby.Server.Implementations/Collections/CollectionManager.cs b/Emby.Server.Implementations/Collections/CollectionManager.cs index 1bbcbe2dd..213c3dccc 100644 --- a/Emby.Server.Implementations/Collections/CollectionManager.cs +++ b/Emby.Server.Implementations/Collections/CollectionManager.cs @@ -210,7 +210,7 @@ namespace Emby.Server.Implementations.Collections var itemList = new List(); var linkedChildrenList = collection.GetLinkedChildren(); - var currentLinkedChildrenIds = linkedChildrenList.Select(i => i.Id); + var currentLinkedChildrenIds = linkedChildrenList.Select(i => i.Id).ToList(); foreach (var id in ids) { @@ -300,7 +300,7 @@ namespace Emby.Server.Implementations.Collections { var results = new Dictionary(); - var allBoxSets = GetCollections(user); + var allBoxSets = GetCollections(user).ToList(); foreach (var item in items) { diff --git a/Emby.Server.Implementations/Library/LibraryManager.cs b/Emby.Server.Implementations/Library/LibraryManager.cs index 9053449ab..c2a1f4dde 100644 --- a/Emby.Server.Implementations/Library/LibraryManager.cs +++ b/Emby.Server.Implementations/Library/LibraryManager.cs @@ -356,7 +356,7 @@ namespace Emby.Server.Implementations.Library } var children = item.IsFolder - ? ((Folder)item).GetRecursiveChildren(false) + ? ((Folder)item).GetRecursiveChildren(false).ToList() : new List(); foreach (var metadataPath in GetMetadataPaths(item, children)) @@ -612,7 +612,8 @@ namespace Emby.Server.Implementations.Library var list = originalList.Where(i => i.IsDirectory) .Select(i => _fileSystem.NormalizePath(i.FullName)) - .Distinct(StringComparer.OrdinalIgnoreCase); + .Distinct(StringComparer.OrdinalIgnoreCase) + .ToList(); var dupes = list.Where(subPath => !subPath.EndsWith(":\\", StringComparison.OrdinalIgnoreCase) && list.Any(i => _fileSystem.ContainsSubPath(i, subPath))); -- cgit v1.2.3 From 08e71010ae3370cb51068eb0215d53f82019fbca Mon Sep 17 00:00:00 2001 From: jgriff6 <74262798+jgriff6@users.noreply.github.com> Date: Tue, 25 Oct 2022 01:40:47 +0100 Subject: Clean up some ToList usage --- Emby.Naming/AudioBook/AudioBookListResolver.cs | 3 ++- Emby.Server.Implementations/Collections/CollectionManager.cs | 5 ++++- Emby.Server.Implementations/Library/LibraryManager.cs | 3 ++- 3 files changed, 8 insertions(+), 3 deletions(-) (limited to 'Emby.Server.Implementations/Collections') diff --git a/Emby.Naming/AudioBook/AudioBookListResolver.cs b/Emby.Naming/AudioBook/AudioBookListResolver.cs index 4a464f8f4..6e491185d 100644 --- a/Emby.Naming/AudioBook/AudioBookListResolver.cs +++ b/Emby.Naming/AudioBook/AudioBookListResolver.cs @@ -101,7 +101,8 @@ namespace Emby.Naming.AudioBook { var extra = ex .OrderBy(x => x.Container) - .ThenBy(x => x.Path); + .ThenBy(x => x.Path) + .ToList(); stackFiles = stackFiles.Except(extra).ToList(); extras.AddRange(extra); diff --git a/Emby.Server.Implementations/Collections/CollectionManager.cs b/Emby.Server.Implementations/Collections/CollectionManager.cs index 213c3dccc..187e0c9b3 100644 --- a/Emby.Server.Implementations/Collections/CollectionManager.cs +++ b/Emby.Server.Implementations/Collections/CollectionManager.cs @@ -232,7 +232,10 @@ namespace Emby.Server.Implementations.Collections if (list.Count > 0) { - collection.LinkedChildren = collection.LinkedChildren.Concat(list).ToArray(); + LinkedChild[] newChildren = new LinkedChild[collection.LinkedChildren.Length + list.Count]; + collection.LinkedChildren.CopyTo(newChildren, 0); + list.CopyTo(newChildren, collection.LinkedChildren.Length); + collection.LinkedChildren = newChildren; collection.UpdateRatingToItems(linkedChildrenList); await collection.UpdateToRepositoryAsync(ItemUpdateType.MetadataEdit, CancellationToken.None).ConfigureAwait(false); diff --git a/Emby.Server.Implementations/Library/LibraryManager.cs b/Emby.Server.Implementations/Library/LibraryManager.cs index c2a1f4dde..cef82ebbc 100644 --- a/Emby.Server.Implementations/Library/LibraryManager.cs +++ b/Emby.Server.Implementations/Library/LibraryManager.cs @@ -615,7 +615,8 @@ namespace Emby.Server.Implementations.Library .Distinct(StringComparer.OrdinalIgnoreCase) .ToList(); - var dupes = list.Where(subPath => !subPath.EndsWith(":\\", StringComparison.OrdinalIgnoreCase) && list.Any(i => _fileSystem.ContainsSubPath(i, subPath))); + var dupes = list.Where(subPath => !subPath.EndsWith(":\\", StringComparison.OrdinalIgnoreCase) && list.Any(i => _fileSystem.ContainsSubPath(i, subPath))) + .ToList(); foreach (var dupe in dupes) { -- cgit v1.2.3