From ee637e8fecbcefe429babbbbd1325bce7c3fe991 Mon Sep 17 00:00:00 2001 From: Bond-009 Date: Mon, 2 Sep 2019 08:19:29 +0200 Subject: Fix warnings, improve performance (#1665) * Fix warnings, improve performance `QueryResult.Items` is now a `IReadOnlyList` so we don't need to allocate a new `Array` when we have a `List` (and `Items` shouldn't need to be mutable anyway) * Update Providers .csproj to latest C# * Remove extra newline from DtoService.cs * Remove extra newline from UserLibraryService.cs --- MediaBrowser.Common/Extensions/CollectionExtensions.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'MediaBrowser.Common/Extensions/CollectionExtensions.cs') diff --git a/MediaBrowser.Common/Extensions/CollectionExtensions.cs b/MediaBrowser.Common/Extensions/CollectionExtensions.cs index f7c0e3cf0..3bc0295a0 100644 --- a/MediaBrowser.Common/Extensions/CollectionExtensions.cs +++ b/MediaBrowser.Common/Extensions/CollectionExtensions.cs @@ -10,5 +10,22 @@ namespace MediaBrowser.Common.Extensions dictionary.TryGetValue(key, out var ret); return ret; } + + // REVIEW: Inline? + /// + /// Copies all the elements of the current collection to the specified list + /// starting at the specified destination array index. The index is specified as a 32-bit integer. + /// + /// The current collection that is the source of the elements. + /// The list that is the destination of the elements copied from the current collection. + /// A 32-bit integer that represents the index in destination at which copying begins. + /// + public static void CopyTo(this IReadOnlyCollection source, IList destination, int index = 0) + { + foreach (T item in source) + { + destination[index++] = item; + } + } } } -- cgit v1.2.3