aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Server.Implementations/Users/DisplayPreferencesManager.cs
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 /Jellyfin.Server.Implementations/Users/DisplayPreferencesManager.cs
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 'Jellyfin.Server.Implementations/Users/DisplayPreferencesManager.cs')
-rw-r--r--Jellyfin.Server.Implementations/Users/DisplayPreferencesManager.cs14
1 files changed, 7 insertions, 7 deletions
diff --git a/Jellyfin.Server.Implementations/Users/DisplayPreferencesManager.cs b/Jellyfin.Server.Implementations/Users/DisplayPreferencesManager.cs
index c89e3c74d..f5d38db20 100644
--- a/Jellyfin.Server.Implementations/Users/DisplayPreferencesManager.cs
+++ b/Jellyfin.Server.Implementations/Users/DisplayPreferencesManager.cs
@@ -32,7 +32,7 @@ namespace Jellyfin.Server.Implementations.Users
var prefs = _dbContext.DisplayPreferences
.Include(pref => pref.HomeSections)
.FirstOrDefault(pref =>
- pref.UserId == userId && string.Equals(pref.Client, client) && pref.ItemId == itemId);
+ pref.UserId.Equals(userId) && string.Equals(pref.Client, client) && pref.ItemId.Equals(itemId));
if (prefs == null)
{
@@ -47,7 +47,7 @@ namespace Jellyfin.Server.Implementations.Users
public ItemDisplayPreferences GetItemDisplayPreferences(Guid userId, Guid itemId, string client)
{
var prefs = _dbContext.ItemDisplayPreferences
- .FirstOrDefault(pref => pref.UserId == userId && pref.ItemId == itemId && string.Equals(pref.Client, client));
+ .FirstOrDefault(pref => pref.UserId.Equals(userId) && pref.ItemId.Equals(itemId) && string.Equals(pref.Client, client));
if (prefs == null)
{
@@ -63,7 +63,7 @@ namespace Jellyfin.Server.Implementations.Users
{
return _dbContext.ItemDisplayPreferences
.AsQueryable()
- .Where(prefs => prefs.UserId == userId && prefs.ItemId != Guid.Empty && string.Equals(prefs.Client, client))
+ .Where(prefs => prefs.UserId.Equals(userId) && !prefs.ItemId.Equals(default) && string.Equals(prefs.Client, client))
.ToList();
}
@@ -72,8 +72,8 @@ namespace Jellyfin.Server.Implementations.Users
{
return _dbContext.CustomItemDisplayPreferences
.AsQueryable()
- .Where(prefs => prefs.UserId == userId
- && prefs.ItemId == itemId
+ .Where(prefs => prefs.UserId.Equals(userId)
+ && prefs.ItemId.Equals(itemId)
&& string.Equals(prefs.Client, client))
.ToDictionary(prefs => prefs.Key, prefs => prefs.Value);
}
@@ -83,8 +83,8 @@ namespace Jellyfin.Server.Implementations.Users
{
var existingPrefs = _dbContext.CustomItemDisplayPreferences
.AsQueryable()
- .Where(prefs => prefs.UserId == userId
- && prefs.ItemId == itemId
+ .Where(prefs => prefs.UserId.Equals(userId)
+ && prefs.ItemId.Equals(itemId)
&& string.Equals(prefs.Client, client));
_dbContext.CustomItemDisplayPreferences.RemoveRange(existingPrefs);