1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2026-04-24 22:36:19 -04:00

Use Length/Count property instead of Count() method to prevent enumerating

This commit is contained in:
Qstick
2023-01-09 22:08:20 -06:00
parent 4fe9daec03
commit e805f61450
14 changed files with 20 additions and 21 deletions
@@ -109,7 +109,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
// Ensure that this is either the first episode
// or is the last episode in a season that has 10 or more episodes
if (seasonEpisodes.First().Id == firstEpisode.Id || (seasonEpisodes.Count() >= 10 && seasonEpisodes.Last().Id == firstEpisode.Id))
if (seasonEpisodes.First().Id == firstEpisode.Id || (seasonEpisodes.Count >= 10 && seasonEpisodes.Last().Id == firstEpisode.Id))
{
_logger.Debug("Possible double episode, doubling allowed size.");
maxSize = maxSize * 2;
@@ -35,7 +35,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
// test against episodes of the same season in the current search, and make sure they have an air date
var subset = searchCriteria.Episodes.Where(e => e.AirDateUtc.HasValue && e.SeasonNumber == subject.Episodes.First().SeasonNumber).ToList();
if (subset.Count() > 0 && subset.Max(e => e.AirDateUtc).Value.Before(DateTime.UtcNow - TimeSpan.FromDays(subject.Release.SeasonSearchMaximumSingleEpisodeAge)))
if (subset.Count > 0 && subset.Max(e => e.AirDateUtc).Value.Before(DateTime.UtcNow - TimeSpan.FromDays(subject.Release.SeasonSearchMaximumSingleEpisodeAge)))
{
_logger.Debug("Release {0}: last episode in this season aired more than {1} days ago, season pack required.", subject.Release.Title, subject.Release.SeasonSearchMaximumSingleEpisodeAge);
return Decision.Reject("Last episode in this season aired more than {0} days ago, season pack required.", subject.Release.SeasonSearchMaximumSingleEpisodeAge);