diff --git a/Emby.Dlna/ContentDirectory/ControlHandler.cs b/Emby.Dlna/ContentDirectory/ControlHandler.cs
index 496f1a9f09..7c30f2c881 100644
--- a/Emby.Dlna/ContentDirectory/ControlHandler.cs
+++ b/Emby.Dlna/ContentDirectory/ControlHandler.cs
@@ -1181,8 +1181,9 @@ namespace Emby.Dlna.ContentDirectory
/// The .
private static QueryResult ToResult(QueryResult result)
{
- var serverItems = new ServerItem[result.Items.Count];
- for (var i = 0; i < result.Items.Count; i++)
+ var length = result.Items.Count;
+ var serverItems = new ServerItem[length];
+ for (var i = 0; i < length; i++)
{
serverItems[i] = new ServerItem(result.Items[i], null);
}
@@ -1201,8 +1202,9 @@ namespace Emby.Dlna.ContentDirectory
/// The .
private static QueryResult ToResult(QueryResult<(BaseItem, ItemCounts)> result)
{
- var serverItems = new ServerItem[result.Items.Count];
- for (var i = 0; i < result.Items.Count; i++)
+ var length = result.Items.Count;
+ var serverItems = new ServerItem[length];
+ for (var i = 0; i < length; i++)
{
serverItems[i] = new ServerItem(result.Items[i].Item1, null);
}