diff --git a/osu.Game/Beatmaps/BeatmapInfoExtensions.cs b/osu.Game/Beatmaps/BeatmapInfoExtensions.cs index 7e336dcde2..7d6667cdcd 100644 --- a/osu.Game/Beatmaps/BeatmapInfoExtensions.cs +++ b/osu.Game/Beatmaps/BeatmapInfoExtensions.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . 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 GetSearchableTerms(this IBeatmapInfo beatmapInfo) + public static ReadOnlySpan GetSearchableTerms(this IBeatmapInfo beatmapInfo) { - var terms = new List(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; } }