Search terms before performing other criteria checks

Very minor, but putting the more common case towards the
start of the method allows early return.
This commit is contained in:
Dean Herbert 2023-12-05 15:28:56 +09:00
parent 42010574b5
commit 45e499778f
No known key found for this signature in database

View File

@ -41,6 +41,21 @@ namespace osu.Game.Screens.Select.Carousel
return match;
}
if (criteria.SearchTerms.Length > 0)
{
match = BeatmapInfo.Match(criteria.SearchTerms);
// if a match wasn't found via text matching of terms, do a second catch-all check matching against online IDs.
// this should be done after text matching so we can prioritise matching numbers in metadata.
if (!match && criteria.SearchNumber.HasValue)
{
match = (BeatmapInfo.OnlineID == criteria.SearchNumber.Value) ||
(BeatmapInfo.BeatmapSet?.OnlineID == criteria.SearchNumber.Value);
}
}
if (!match) return false;
match &= !criteria.StarDifficulty.HasFilter || criteria.StarDifficulty.IsInRange(BeatmapInfo.StarRating);
match &= !criteria.ApproachRate.HasFilter || criteria.ApproachRate.IsInRange(BeatmapInfo.Difficulty.ApproachRate);
match &= !criteria.DrainRate.HasFilter || criteria.DrainRate.IsInRange(BeatmapInfo.Difficulty.DrainRate);
@ -64,21 +79,6 @@ namespace osu.Game.Screens.Select.Carousel
if (!match) return false;
if (criteria.SearchTerms.Length > 0)
{
match = BeatmapInfo.Match(criteria.SearchTerms);
// if a match wasn't found via text matching of terms, do a second catch-all check matching against online IDs.
// this should be done after text matching so we can prioritise matching numbers in metadata.
if (!match && criteria.SearchNumber.HasValue)
{
match = (BeatmapInfo.OnlineID == criteria.SearchNumber.Value) ||
(BeatmapInfo.BeatmapSet?.OnlineID == criteria.SearchNumber.Value);
}
}
if (!match) return false;
match &= criteria.CollectionBeatmapMD5Hashes?.Contains(BeatmapInfo.MD5Hash) ?? true;
if (match && criteria.RulesetCriteria != null)
match &= criteria.RulesetCriteria.Matches(BeatmapInfo);