aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/LiveTv
diff options
context:
space:
mode:
authorBond_009 <bond.009@outlook.com>2022-02-21 14:15:09 +0100
committerBond_009 <bond.009@outlook.com>2022-02-21 14:15:09 +0100
commitf50a250cd9fac47bcbd9a05e99c8ffe4d294e320 (patch)
treeb205dccb83ad385b0ac338b00680aa4f97fe9b97 /Emby.Server.Implementations/LiveTv
parentbbac59c6d627ef3ef67e26b10d6571cd9a260466 (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/LiveTv')
-rw-r--r--Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs6
-rw-r--r--Emby.Server.Implementations/LiveTv/LiveTvDtoService.cs4
-rw-r--r--Emby.Server.Implementations/LiveTv/LiveTvManager.cs18
3 files changed, 16 insertions, 12 deletions
diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs
index bba584854..2753cf177 100644
--- a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs
+++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs
@@ -2024,7 +2024,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
await writer.WriteElementStringAsync(null, "genre", null, genre).ConfigureAwait(false);
}
- var people = item.Id.Equals(Guid.Empty) ? new List<PersonInfo>() : _libraryManager.GetPeople(item);
+ var people = item.Id.Equals(default) ? new List<PersonInfo>() : _libraryManager.GetPeople(item);
var directors = people
.Where(i => IsPersonType(i, PersonType.Director))
@@ -2382,7 +2382,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
{
string channelId = seriesTimer.RecordAnyChannel ? null : seriesTimer.ChannelId;
- if (string.IsNullOrWhiteSpace(channelId) && !parent.ChannelId.Equals(Guid.Empty))
+ if (string.IsNullOrWhiteSpace(channelId) && !parent.ChannelId.Equals(default))
{
if (!tempChannelCache.TryGetValue(parent.ChannelId, out LiveTvChannel channel))
{
@@ -2441,7 +2441,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
{
string channelId = null;
- if (!programInfo.ChannelId.Equals(Guid.Empty))
+ if (!programInfo.ChannelId.Equals(default))
{
if (!tempChannelCache.TryGetValue(programInfo.ChannelId, out LiveTvChannel channel))
{
diff --git a/Emby.Server.Implementations/LiveTv/LiveTvDtoService.cs b/Emby.Server.Implementations/LiveTv/LiveTvDtoService.cs
index fbce7af2d..c09f9cf8d 100644
--- a/Emby.Server.Implementations/LiveTv/LiveTvDtoService.cs
+++ b/Emby.Server.Implementations/LiveTv/LiveTvDtoService.cs
@@ -456,7 +456,7 @@ namespace Emby.Server.Implementations.LiveTv
info.Id = timer.ExternalId;
}
- if (!dto.ChannelId.Equals(Guid.Empty) && string.IsNullOrEmpty(info.ChannelId))
+ if (!dto.ChannelId.Equals(default) && string.IsNullOrEmpty(info.ChannelId))
{
var channel = _libraryManager.GetItemById(dto.ChannelId);
@@ -522,7 +522,7 @@ namespace Emby.Server.Implementations.LiveTv
info.Id = timer.ExternalId;
}
- if (!dto.ChannelId.Equals(Guid.Empty) && string.IsNullOrEmpty(info.ChannelId))
+ if (!dto.ChannelId.Equals(default) && string.IsNullOrEmpty(info.ChannelId))
{
var channel = _libraryManager.GetItemById(dto.ChannelId);
diff --git a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs
index 71a29e3cb..97c2e6e30 100644
--- a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs
+++ b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs
@@ -176,7 +176,9 @@ namespace Emby.Server.Implementations.LiveTv
public QueryResult<BaseItem> GetInternalChannels(LiveTvChannelQuery query, DtoOptions dtoOptions, CancellationToken cancellationToken)
{
- var user = query.UserId == Guid.Empty ? null : _userManager.GetUserById(query.UserId);
+ var user = query.UserId.Equals(default)
+ ? null
+ : _userManager.GetUserById(query.UserId);
var topFolder = GetInternalLiveTvFolder(cancellationToken);
@@ -1268,7 +1270,7 @@ namespace Emby.Server.Implementations.LiveTv
{
cancellationToken.ThrowIfCancellationRequested();
- if (itemId.Equals(Guid.Empty))
+ if (itemId.Equals(default))
{
// Somehow some invalid data got into the db. It probably predates the boundary checking
continue;
@@ -1528,7 +1530,9 @@ namespace Emby.Server.Implementations.LiveTv
public QueryResult<BaseItemDto> GetRecordings(RecordingQuery query, DtoOptions options)
{
- var user = query.UserId.Equals(Guid.Empty) ? null : _userManager.GetUserById(query.UserId);
+ var user = query.UserId.Equals(default)
+ ? null
+ : _userManager.GetUserById(query.UserId);
RemoveFields(options);
@@ -1587,7 +1591,7 @@ namespace Emby.Server.Implementations.LiveTv
if (!string.IsNullOrEmpty(query.ChannelId))
{
var guid = new Guid(query.ChannelId);
- timers = timers.Where(i => guid == _tvDtoService.GetInternalChannelId(i.Item2.Name, i.Item1.ChannelId));
+ timers = timers.Where(i => _tvDtoService.GetInternalChannelId(i.Item2.Name, i.Item1.ChannelId).Equals(guid));
}
if (!string.IsNullOrEmpty(query.SeriesTimerId))
@@ -1595,7 +1599,7 @@ namespace Emby.Server.Implementations.LiveTv
var guid = new Guid(query.SeriesTimerId);
timers = timers
- .Where(i => _tvDtoService.GetInternalSeriesTimerId(i.Item1.SeriesTimerId) == guid);
+ .Where(i => _tvDtoService.GetInternalSeriesTimerId(i.Item1.SeriesTimerId).Equals(guid));
}
if (!string.IsNullOrEmpty(query.Id))
@@ -1657,7 +1661,7 @@ namespace Emby.Server.Implementations.LiveTv
if (!string.IsNullOrEmpty(query.ChannelId))
{
var guid = new Guid(query.ChannelId);
- timers = timers.Where(i => guid == _tvDtoService.GetInternalChannelId(i.Item2.Name, i.Item1.ChannelId));
+ timers = timers.Where(i => _tvDtoService.GetInternalChannelId(i.Item2.Name, i.Item1.ChannelId).Equals(guid));
}
if (!string.IsNullOrEmpty(query.SeriesTimerId))
@@ -1665,7 +1669,7 @@ namespace Emby.Server.Implementations.LiveTv
var guid = new Guid(query.SeriesTimerId);
timers = timers
- .Where(i => _tvDtoService.GetInternalSeriesTimerId(i.Item1.SeriesTimerId) == guid);
+ .Where(i => _tvDtoService.GetInternalSeriesTimerId(i.Item1.SeriesTimerId).Equals(guid));
}
if (!string.IsNullOrEmpty(query.Id))