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
This commit is contained in:
Bond_009
2022-02-21 14:15:09 +01:00
parent bbac59c6d6
commit f50a250cd9
66 changed files with 355 additions and 326 deletions

View File

@@ -213,7 +213,7 @@ namespace MediaBrowser.Controller.Entities
{
item.SetParent(this);
if (item.Id.Equals(Guid.Empty))
if (item.Id.Equals(default))
{
item.Id = LibraryManager.GetNewItemId(item.Path, item.GetType());
}
@@ -730,7 +730,9 @@ namespace MediaBrowser.Controller.Entities
return PostFilterAndSort(items, query, true);
}
if (this is not UserRootFolder && this is not AggregateFolder && query.ParentId == Guid.Empty)
if (this is not UserRootFolder
&& this is not AggregateFolder
&& query.ParentId.Equals(default))
{
query.Parent = this;
}
@@ -1492,7 +1494,7 @@ namespace MediaBrowser.Controller.Entities
{
if (i.ItemId.HasValue)
{
if (i.ItemId.Value == itemId)
if (i.ItemId.Value.Equals(itemId))
{
return true;
}
@@ -1502,7 +1504,7 @@ namespace MediaBrowser.Controller.Entities
var child = GetLinkedChild(i);
if (child != null && child.Id == itemId)
if (child != null && child.Id.Equals(itemId))
{
return true;
}