Minor perf improvements

This commit is contained in:
Bond_009
2020-11-06 16:15:30 +01:00
parent f172b37401
commit b21919c7f4
12 changed files with 42 additions and 39 deletions

View File

@@ -250,21 +250,16 @@ namespace Emby.Server.Implementations.Channels
var all = channels;
var totalCount = all.Count;
if (query.StartIndex.HasValue)
if (query.StartIndex.HasValue || query.Limit.HasValue)
{
all = all.Skip(query.StartIndex.Value).ToList();
int startIndex = query.StartIndex ?? 0;
int count = query.Limit == null ? totalCount - startIndex : Math.Min(query.Limit.Value, totalCount - startIndex);
all = all.GetRange(startIndex, count);
}
if (query.Limit.HasValue)
{
all = all.Take(query.Limit.Value).ToList();
}
var returnItems = all.ToArray();
if (query.RefreshLatestChannelItems)
{
foreach (var item in returnItems)
foreach (var item in all)
{
RefreshLatestChannelItems(GetChannelProvider(item), CancellationToken.None).GetAwaiter().GetResult();
}
@@ -272,7 +267,7 @@ namespace Emby.Server.Implementations.Channels
return new QueryResult<Channel>
{
Items = returnItems,
Items = all,
TotalRecordCount = totalCount
};
}