Removed some excess looping

This commit is contained in:
LukePulverenti Luke Pulverenti luke pulverenti 2012-09-11 10:35:04 -04:00
parent af7744a1fd
commit 016590529f

View File

@ -218,15 +218,14 @@ namespace MediaBrowser.Controller.Entities
{ {
itemSet = itemSet.Where(i => !(i.IsFolder)); itemSet = itemSet.Where(i => !(i.IsFolder));
if (!itemSet.Any())
{
return 0;
}
decimal totalPercent = 0; decimal totalPercent = 0;
int count = 0;
foreach (BaseItem item in itemSet) foreach (BaseItem item in itemSet)
{ {
count++;
UserItemData data = item.GetUserData(user, false); UserItemData data = item.GetUserData(user, false);
if (data == null) if (data == null)
@ -246,7 +245,12 @@ namespace MediaBrowser.Controller.Entities
} }
} }
return totalPercent / itemSet.Count(); if (count == 0)
{
return 0;
}
return totalPercent / count;
} }
/// <summary> /// <summary>