Use nullable comparison helper method instead of manual implementation

This commit is contained in:
Dean Herbert 2023-03-06 15:16:31 +09:00
parent a14dede036
commit 87d0bef313
1 changed files with 2 additions and 10 deletions

View File

@ -87,7 +87,7 @@ public override int CompareTo(FilterCriteria criteria, CarouselItem other)
break;
case SortMode.DateRanked:
comparison = compareNullableDateTimeOffset(BeatmapSet.DateRanked, otherSet.BeatmapSet.DateRanked);
comparison = Nullable.Compare(otherSet.BeatmapSet.DateRanked, BeatmapSet.DateRanked);
break;
case SortMode.LastPlayed:
@ -107,7 +107,7 @@ public override int CompareTo(FilterCriteria criteria, CarouselItem other)
break;
case SortMode.DateSubmitted:
comparison = compareNullableDateTimeOffset(BeatmapSet.DateSubmitted, otherSet.BeatmapSet.DateSubmitted);
comparison = Nullable.Compare(otherSet.BeatmapSet.DateSubmitted, BeatmapSet.DateSubmitted);
break;
}
@ -124,14 +124,6 @@ public override int CompareTo(FilterCriteria criteria, CarouselItem other)
return otherSet.BeatmapSet.ID.CompareTo(BeatmapSet.ID);
}
private static int compareNullableDateTimeOffset(DateTimeOffset? x, DateTimeOffset? y)
{
if (x == null) return 1;
if (y == null) return -1;
return y.Value.CompareTo(x.Value);
}
/// <summary>
/// All beatmaps which are not filtered and valid for display.
/// </summary>