mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-18 00:06:27 +01:00
Use ArgumentNullException.ThrowIfNull helper method
Did a simple search/replace on the whole repo (except the RSSDP project)
This reduces LOC and should improve performance (methods containing a throw statement don't get inlined)
```
if \((\w+) == null\)
\s+\{
\s+throw new ArgumentNullException\((.*)\);
\s+\}
```
```
ArgumentNullException.ThrowIfNull($1);
```
This commit is contained in:
@@ -24,15 +24,9 @@ namespace Emby.Server.Implementations.Sorting
|
||||
/// <returns>System.Int32.</returns>
|
||||
public int Compare(BaseItem? x, BaseItem? y)
|
||||
{
|
||||
if (x == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(x));
|
||||
}
|
||||
ArgumentNullException.ThrowIfNull(x);
|
||||
|
||||
if (y == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(y));
|
||||
}
|
||||
ArgumentNullException.ThrowIfNull(y);
|
||||
|
||||
var episode1 = x as Episode;
|
||||
var episode2 = y as Episode;
|
||||
|
||||
@@ -23,15 +23,9 @@ namespace Emby.Server.Implementations.Sorting
|
||||
/// <returns>System.Int32.</returns>
|
||||
public int Compare(BaseItem? x, BaseItem? y)
|
||||
{
|
||||
if (x == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(x));
|
||||
}
|
||||
ArgumentNullException.ThrowIfNull(x);
|
||||
|
||||
if (y == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(y));
|
||||
}
|
||||
ArgumentNullException.ThrowIfNull(y);
|
||||
|
||||
return (x.CommunityRating ?? 0).CompareTo(y.CommunityRating ?? 0);
|
||||
}
|
||||
|
||||
@@ -24,15 +24,9 @@ namespace Emby.Server.Implementations.Sorting
|
||||
/// <returns>System.Int32.</returns>
|
||||
public int Compare(BaseItem? x, BaseItem? y)
|
||||
{
|
||||
if (x == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(x));
|
||||
}
|
||||
ArgumentNullException.ThrowIfNull(x);
|
||||
|
||||
if (y == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(y));
|
||||
}
|
||||
ArgumentNullException.ThrowIfNull(y);
|
||||
|
||||
return DateTime.Compare(x.DateCreated, y.DateCreated);
|
||||
}
|
||||
|
||||
@@ -24,15 +24,9 @@ namespace Emby.Server.Implementations.Sorting
|
||||
/// <returns>System.Int32.</returns>
|
||||
public int Compare(BaseItem? x, BaseItem? y)
|
||||
{
|
||||
if (x == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(x));
|
||||
}
|
||||
ArgumentNullException.ThrowIfNull(x);
|
||||
|
||||
if (y == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(y));
|
||||
}
|
||||
ArgumentNullException.ThrowIfNull(y);
|
||||
|
||||
if (!x.IndexNumber.HasValue && !y.IndexNumber.HasValue)
|
||||
{
|
||||
|
||||
@@ -24,15 +24,9 @@ namespace Emby.Server.Implementations.Sorting
|
||||
/// <returns>System.Int32.</returns>
|
||||
public int Compare(BaseItem? x, BaseItem? y)
|
||||
{
|
||||
if (x == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(x));
|
||||
}
|
||||
ArgumentNullException.ThrowIfNull(x);
|
||||
|
||||
if (y == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(y));
|
||||
}
|
||||
ArgumentNullException.ThrowIfNull(y);
|
||||
|
||||
return string.Compare(x.Name, y.Name, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
@@ -31,15 +31,9 @@ namespace Emby.Server.Implementations.Sorting
|
||||
/// <returns>System.Int32.</returns>
|
||||
public int Compare(BaseItem? x, BaseItem? y)
|
||||
{
|
||||
if (x == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(x));
|
||||
}
|
||||
ArgumentNullException.ThrowIfNull(x);
|
||||
|
||||
if (y == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(y));
|
||||
}
|
||||
ArgumentNullException.ThrowIfNull(y);
|
||||
|
||||
var levelX = string.IsNullOrEmpty(x.OfficialRating) ? 0 : _localization.GetRatingLevel(x.OfficialRating) ?? 0;
|
||||
var levelY = string.IsNullOrEmpty(y.OfficialRating) ? 0 : _localization.GetRatingLevel(y.OfficialRating) ?? 0;
|
||||
|
||||
@@ -24,15 +24,9 @@ namespace Emby.Server.Implementations.Sorting
|
||||
/// <returns>System.Int32.</returns>
|
||||
public int Compare(BaseItem? x, BaseItem? y)
|
||||
{
|
||||
if (x == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(x));
|
||||
}
|
||||
ArgumentNullException.ThrowIfNull(x);
|
||||
|
||||
if (y == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(y));
|
||||
}
|
||||
ArgumentNullException.ThrowIfNull(y);
|
||||
|
||||
if (!x.ParentIndexNumber.HasValue && !y.ParentIndexNumber.HasValue)
|
||||
{
|
||||
|
||||
@@ -26,15 +26,9 @@ namespace Emby.Server.Implementations.Sorting
|
||||
/// <returns>System.Int32.</returns>
|
||||
public int Compare(BaseItem x, BaseItem y)
|
||||
{
|
||||
if (x == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(x));
|
||||
}
|
||||
ArgumentNullException.ThrowIfNull(x);
|
||||
|
||||
if (y == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(y));
|
||||
}
|
||||
ArgumentNullException.ThrowIfNull(y);
|
||||
|
||||
return (x.RunTimeTicks ?? 0).CompareTo(y.RunTimeTicks ?? 0);
|
||||
}
|
||||
|
||||
@@ -26,15 +26,9 @@ namespace Emby.Server.Implementations.Sorting
|
||||
/// <returns>System.Int32.</returns>
|
||||
public int Compare(BaseItem x, BaseItem y)
|
||||
{
|
||||
if (x == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(x));
|
||||
}
|
||||
ArgumentNullException.ThrowIfNull(x);
|
||||
|
||||
if (y == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(y));
|
||||
}
|
||||
ArgumentNullException.ThrowIfNull(y);
|
||||
|
||||
return string.Compare(x.SortName, y.SortName, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
@@ -26,15 +26,9 @@ namespace Emby.Server.Implementations.Sorting
|
||||
/// <returns>System.Int32.</returns>
|
||||
public int Compare(BaseItem x, BaseItem y)
|
||||
{
|
||||
if (x == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(x));
|
||||
}
|
||||
ArgumentNullException.ThrowIfNull(x);
|
||||
|
||||
if (y == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(y));
|
||||
}
|
||||
ArgumentNullException.ThrowIfNull(y);
|
||||
|
||||
return AlphanumericComparator.CompareValues(x.Studios.FirstOrDefault(), y.Studios.FirstOrDefault());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user