diff options
| author | Claus Vium <cvium@users.noreply.github.com> | 2020-11-06 17:11:01 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-11-06 17:11:01 +0100 |
| commit | 6afd990986d70ac24d1acf5c0e1b951e20a5a142 (patch) | |
| tree | 3f5c0090ed308d54e37d3456a85516868dd1145a /Emby.Server.Implementations/Channels/ChannelManager.cs | |
| parent | e6480066b13d5c1aed73bcec291c3f2f35f26506 (diff) | |
| parent | 134fd0d9604ab2108e5008205ede3444aa1a7610 (diff) | |
Merge pull request #4424 from jellyfin/minor8
Minor perf improvements
Diffstat (limited to 'Emby.Server.Implementations/Channels/ChannelManager.cs')
| -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 }; } |
