From 016590529f1dde1b2bcfa6c64aa07ea866f26b51 Mon Sep 17 00:00:00 2001 From: LukePulverenti Luke Pulverenti luke pulverenti Date: Tue, 11 Sep 2012 10:35:04 -0400 Subject: [PATCH] Removed some excess looping --- MediaBrowser.Controller/Entities/Folder.cs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index a9c92c1fa..c0f1604b1 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -218,15 +218,14 @@ namespace MediaBrowser.Controller.Entities { itemSet = itemSet.Where(i => !(i.IsFolder)); - if (!itemSet.Any()) - { - return 0; - } - decimal totalPercent = 0; + int count = 0; + foreach (BaseItem item in itemSet) { + count++; + UserItemData data = item.GetUserData(user, false); if (data == null) @@ -246,7 +245,12 @@ namespace MediaBrowser.Controller.Entities } } - return totalPercent / itemSet.Count(); + if (count == 0) + { + return 0; + } + + return totalPercent / count; } ///