mirror of
https://github.com/ppy/osu.git
synced 2024-11-07 16:07:25 +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.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Localisation;
|
||||
|
||||
namespace osu.Game.Beatmaps
|
||||
@ -29,28 +29,25 @@ namespace osu.Game.Beatmaps
|
||||
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];
|
||||
int i = 0;
|
||||
if (!string.IsNullOrEmpty(beatmapInfo.DifficultyName))
|
||||
terms[i++] = beatmapInfo.DifficultyName;
|
||||
var terms = new List<string>(8);
|
||||
var metadata = beatmapInfo.Metadata;
|
||||
if (!string.IsNullOrEmpty(metadata.Author.Username))
|
||||
terms[i++] = metadata.Author.Username;
|
||||
if (!string.IsNullOrEmpty(metadata.Artist))
|
||||
terms[i++] = metadata.Artist;
|
||||
if (!string.IsNullOrEmpty(metadata.ArtistUnicode))
|
||||
terms[i++] = metadata.ArtistUnicode;
|
||||
if (!string.IsNullOrEmpty(metadata.Title))
|
||||
terms[i++] = metadata.Title;
|
||||
if (!string.IsNullOrEmpty(metadata.TitleUnicode))
|
||||
terms[i++] = metadata.TitleUnicode;
|
||||
if (!string.IsNullOrEmpty(metadata.Source))
|
||||
terms[i++] = metadata.Source;
|
||||
if (!string.IsNullOrEmpty(metadata.Tags))
|
||||
terms[i++] = metadata.Tags;
|
||||
return terms[..i];
|
||||
addIfNotNull(beatmapInfo.DifficultyName);
|
||||
addIfNotNull(metadata.Author.Username);
|
||||
addIfNotNull(metadata.Artist);
|
||||
addIfNotNull(metadata.ArtistUnicode);
|
||||
addIfNotNull(metadata.Title);
|
||||
addIfNotNull(metadata.TitleUnicode);
|
||||
addIfNotNull(metadata.Source);
|
||||
addIfNotNull(metadata.Tags);
|
||||
return terms;
|
||||
|
||||
void addIfNotNull(string? s)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(s))
|
||||
terms.Add(s);
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
// ReSharper disable once LoopCanBeConvertedToQuery
|
||||
// ReSharper disable once ForeachCanBeConvertedToQueryUsingAnotherGetEnumerator
|
||||
foreach (string term in terms)
|
||||
{
|
||||
if (!term.Contains(criteriaTerm, StringComparison.InvariantCultureIgnoreCase)) continue;
|
||||
|
Loading…
Reference in New Issue
Block a user