1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-26 18:03:11 +08:00

using array again in GetSearchableTerms

This commit is contained in:
OliBomby 2023-03-04 16:49:46 +01:00
parent 70a925aab1
commit 5146f7c978

View File

@ -1,6 +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;
@ -29,9 +30,10 @@ namespace osu.Game.Beatmaps
return new RomanisableString($"{metadata.GetPreferred(true)}".Trim(), $"{metadata.GetPreferred(false)}".Trim());
}
public static List<string> GetSearchableTerms(this IBeatmapInfo beatmapInfo)
public static ReadOnlySpan<string> GetSearchableTerms(this IBeatmapInfo beatmapInfo)
{
var terms = new List<string>(8);
string[] terms = new string[8];
int i = 0;
var metadata = beatmapInfo.Metadata;
addIfNotNull(beatmapInfo.DifficultyName);
addIfNotNull(metadata.Author.Username);
@ -41,12 +43,12 @@ namespace osu.Game.Beatmaps
addIfNotNull(metadata.TitleUnicode);
addIfNotNull(metadata.Source);
addIfNotNull(metadata.Tags);
return terms;
return terms.AsSpan(0, i);
void addIfNotNull(string? s)
{
if (!string.IsNullOrEmpty(s))
terms.Add(s);
terms[i++] = s;
}
}