aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Common/Extensions/CollectionExtensions.cs
diff options
context:
space:
mode:
authorBond-009 <bond.009@outlook.com>2019-09-02 08:19:29 +0200
committerAnthony Lavado <anthonylavado@users.noreply.github.com>2019-09-02 02:19:29 -0400
commitee637e8fecbcefe429babbbbd1325bce7c3fe991 (patch)
treee3d76fb8d753dd43d8d0cff16e199b706ba84980 /MediaBrowser.Common/Extensions/CollectionExtensions.cs
parentcb393c215a2ea75f61d0e3e798c6a4a596d720c2 (diff)
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
Diffstat (limited to 'MediaBrowser.Common/Extensions/CollectionExtensions.cs')
-rw-r--r--MediaBrowser.Common/Extensions/CollectionExtensions.cs17
1 files changed, 17 insertions, 0 deletions
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?
+ /// <summary>
+ /// 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.
+ /// </summary>
+ /// <param name="source">The current collection that is the source of the elements.</param>
+ /// <param name="destination">The list that is the destination of the elements copied from the current collection.</param>
+ /// <param name="index">A 32-bit integer that represents the index in <c>destination</c> at which copying begins.</param>
+ /// <typeparam name="T"></typeparam>
+ public static void CopyTo<T>(this IReadOnlyCollection<T> source, IList<T> destination, int index = 0)
+ {
+ foreach (T item in source)
+ {
+ destination[index++] = item;
+ }
+ }
}
}