diff options
| author | Bond_009 <bond.009@outlook.com> | 2020-11-06 16:15:30 +0100 |
|---|---|---|
| committer | Bond_009 <bond.009@outlook.com> | 2020-11-06 16:15:30 +0100 |
| commit | b21919c7f40770c909a0fc217bf2a326397f84f7 (patch) | |
| tree | d930ff0a8868bd1f6d45e6450ce626d6e4d4b79a /Emby.Server.Implementations | |
| parent | f172b37401585bbcc72708bd1b34f4875ced1a76 (diff) | |
Minor perf improvements
Diffstat (limited to 'Emby.Server.Implementations')
| -rw-r--r-- | Emby.Server.Implementations/Channels/ChannelManager.cs | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/Emby.Server.Implementations/Channels/ChannelManager.cs b/Emby.Server.Implementations/Channels/ChannelManager.cs index db44bf489..19045b72b 100644 --- a/Emby.Server.Implementations/Channels/ChannelManager.cs +++ b/Emby.Server.Implementations/Channels/ChannelManager.cs @@ -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 }; } |
