mirror of
https://github.com/ppy/osu.git
synced 2024-11-07 18:07:28 +08:00
using List instead of Span in GetSearchableTerms
This commit is contained in:
parent
3185418834
commit
b90c389ff0
@ -1,7 +1,7 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System.Collections.Generic;
|
||||||
using osu.Framework.Localisation;
|
using osu.Framework.Localisation;
|
||||||
|
|
||||||
namespace osu.Game.Beatmaps
|
namespace osu.Game.Beatmaps
|
||||||
@ -29,28 +29,25 @@ namespace osu.Game.Beatmaps
|
|||||||
return new RomanisableString($"{metadata.GetPreferred(true)}".Trim(), $"{metadata.GetPreferred(false)}".Trim());
|
return new RomanisableString($"{metadata.GetPreferred(true)}".Trim(), $"{metadata.GetPreferred(false)}".Trim());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ReadOnlySpan<string> GetSearchableTerms(this IBeatmapInfo beatmapInfo)
|
public static List<string> GetSearchableTerms(this IBeatmapInfo beatmapInfo)
|
||||||
{
|
{
|
||||||
Span<string> terms = new string[8];
|
var terms = new List<string>(8);
|
||||||
int i = 0;
|
|
||||||
if (!string.IsNullOrEmpty(beatmapInfo.DifficultyName))
|
|
||||||
terms[i++] = beatmapInfo.DifficultyName;
|
|
||||||
var metadata = beatmapInfo.Metadata;
|
var metadata = beatmapInfo.Metadata;
|
||||||
if (!string.IsNullOrEmpty(metadata.Author.Username))
|
addIfNotNull(beatmapInfo.DifficultyName);
|
||||||
terms[i++] = metadata.Author.Username;
|
addIfNotNull(metadata.Author.Username);
|
||||||
if (!string.IsNullOrEmpty(metadata.Artist))
|
addIfNotNull(metadata.Artist);
|
||||||
terms[i++] = metadata.Artist;
|
addIfNotNull(metadata.ArtistUnicode);
|
||||||
if (!string.IsNullOrEmpty(metadata.ArtistUnicode))
|
addIfNotNull(metadata.Title);
|
||||||
terms[i++] = metadata.ArtistUnicode;
|
addIfNotNull(metadata.TitleUnicode);
|
||||||
if (!string.IsNullOrEmpty(metadata.Title))
|
addIfNotNull(metadata.Source);
|
||||||
terms[i++] = metadata.Title;
|
addIfNotNull(metadata.Tags);
|
||||||
if (!string.IsNullOrEmpty(metadata.TitleUnicode))
|
return terms;
|
||||||
terms[i++] = metadata.TitleUnicode;
|
|
||||||
if (!string.IsNullOrEmpty(metadata.Source))
|
void addIfNotNull(string? s)
|
||||||
terms[i++] = metadata.Source;
|
{
|
||||||
if (!string.IsNullOrEmpty(metadata.Tags))
|
if (!string.IsNullOrEmpty(s))
|
||||||
terms[i++] = metadata.Tags;
|
terms.Add(s);
|
||||||
return terms[..i];
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string getVersionString(IBeatmapInfo beatmapInfo) => string.IsNullOrEmpty(beatmapInfo.DifficultyName) ? string.Empty : $"[{beatmapInfo.DifficultyName}]";
|
private static string getVersionString(IBeatmapInfo beatmapInfo) => string.IsNullOrEmpty(beatmapInfo.DifficultyName) ? string.Empty : $"[{beatmapInfo.DifficultyName}]";
|
||||||
|
@ -69,7 +69,7 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
{
|
{
|
||||||
bool any = false;
|
bool any = false;
|
||||||
|
|
||||||
// ReSharper disable once LoopCanBeConvertedToQuery
|
// ReSharper disable once ForeachCanBeConvertedToQueryUsingAnotherGetEnumerator
|
||||||
foreach (string term in terms)
|
foreach (string term in terms)
|
||||||
{
|
{
|
||||||
if (!term.Contains(criteriaTerm, StringComparison.InvariantCultureIgnoreCase)) continue;
|
if (!term.Contains(criteriaTerm, StringComparison.InvariantCultureIgnoreCase)) continue;
|
||||||
|
Loading…
Reference in New Issue
Block a user