diff options
| author | Bond_009 <bond.009@outlook.com> | 2022-02-21 14:15:09 +0100 |
|---|---|---|
| committer | Bond_009 <bond.009@outlook.com> | 2022-02-21 14:15:09 +0100 |
| commit | f50a250cd9fac47bcbd9a05e99c8ffe4d294e320 (patch) | |
| tree | b205dccb83ad385b0ac338b00680aa4f97fe9b97 /Emby.Server.Implementations/Channels/ChannelManager.cs | |
| parent | bbac59c6d627ef3ef67e26b10d6571cd9a260466 (diff) | |
Optimize Guid comparisons
* Use Guid.Equals(Guid) instead of the == override
* Ban the usage of Guid.Equals(Object) to prevent accidental boxing
* Compare to default(Guid) instead of Guid.Empty
Diffstat (limited to 'Emby.Server.Implementations/Channels/ChannelManager.cs')
| -rw-r--r-- | Emby.Server.Implementations/Channels/ChannelManager.cs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/Emby.Server.Implementations/Channels/ChannelManager.cs b/Emby.Server.Implementations/Channels/ChannelManager.cs index 09429c73f..92a85e862 100644 --- a/Emby.Server.Implementations/Channels/ChannelManager.cs +++ b/Emby.Server.Implementations/Channels/ChannelManager.cs @@ -162,7 +162,7 @@ namespace Emby.Server.Implementations.Channels /// <inheritdoc /> public QueryResult<Channel> GetChannelsInternal(ChannelQuery query) { - var user = query.UserId.Equals(Guid.Empty) + var user = query.UserId.Equals(default) ? null : _userManager.GetUserById(query.UserId); @@ -274,7 +274,7 @@ namespace Emby.Server.Implementations.Channels /// <inheritdoc /> public QueryResult<BaseItemDto> GetChannels(ChannelQuery query) { - var user = query.UserId.Equals(Guid.Empty) + var user = query.UserId.Equals(default) ? null : _userManager.GetUserById(query.UserId); @@ -474,7 +474,7 @@ namespace Emby.Server.Implementations.Channels item.ChannelId = id; - if (item.ParentId != parentFolderId) + if (!item.ParentId.Equals(parentFolderId)) { forceUpdate = true; } @@ -715,7 +715,9 @@ namespace Emby.Server.Implementations.Channels // Find the corresponding channel provider plugin var channelProvider = GetChannelProvider(channel); - var parentItem = query.ParentId == Guid.Empty ? channel : _libraryManager.GetItemById(query.ParentId); + var parentItem = query.ParentId.Equals(default) + ? channel + : _libraryManager.GetItemById(query.ParentId); var itemsResult = await GetChannelItems( channelProvider, @@ -726,7 +728,7 @@ namespace Emby.Server.Implementations.Channels cancellationToken) .ConfigureAwait(false); - if (query.ParentId == Guid.Empty) + if (query.ParentId.Equals(default)) { query.Parent = channel; } |
