mirror of
https://github.com/osukey/osukey.git
synced 2025-06-05 12:57:39 +09:00
using array again in GetSearchableTerms
This commit is contained in:
parent
70a925aab1
commit
5146f7c978
@ -1,6 +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 System.Collections.Generic;
|
||||||
using osu.Framework.Localisation;
|
using osu.Framework.Localisation;
|
||||||
|
|
||||||
@ -29,9 +30,10 @@ 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 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;
|
var metadata = beatmapInfo.Metadata;
|
||||||
addIfNotNull(beatmapInfo.DifficultyName);
|
addIfNotNull(beatmapInfo.DifficultyName);
|
||||||
addIfNotNull(metadata.Author.Username);
|
addIfNotNull(metadata.Author.Username);
|
||||||
@ -41,12 +43,12 @@ namespace osu.Game.Beatmaps
|
|||||||
addIfNotNull(metadata.TitleUnicode);
|
addIfNotNull(metadata.TitleUnicode);
|
||||||
addIfNotNull(metadata.Source);
|
addIfNotNull(metadata.Source);
|
||||||
addIfNotNull(metadata.Tags);
|
addIfNotNull(metadata.Tags);
|
||||||
return terms;
|
return terms.AsSpan(0, i);
|
||||||
|
|
||||||
void addIfNotNull(string? s)
|
void addIfNotNull(string? s)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(s))
|
if (!string.IsNullOrEmpty(s))
|
||||||
terms.Add(s);
|
terms[i++] = s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user