Use Ruleset's ShortName for mod caching purposes

This commit is contained in:
Dean Herbert 2021-11-22 16:52:54 +09:00
parent 1020fb7323
commit 377ba2673a

View File

@ -39,7 +39,7 @@ namespace osu.Game.Rulesets
{
public RulesetInfo RulesetInfo { get; internal set; }
private static readonly ConcurrentDictionary<int, IMod[]> mod_reference_cache = new ConcurrentDictionary<int, IMod[]>();
private static readonly ConcurrentDictionary<string, IMod[]> mod_reference_cache = new ConcurrentDictionary<string, IMod[]>();
/// <summary>
/// A queryable source containing all available mods.
@ -49,11 +49,8 @@ namespace osu.Game.Rulesets
{
get
{
if (!(RulesetInfo.ID is int id))
return CreateAllMods();
if (!mod_reference_cache.TryGetValue(id, out var mods))
mod_reference_cache[id] = mods = CreateAllMods().Cast<IMod>().ToArray();
if (!mod_reference_cache.TryGetValue(ShortName, out var mods))
mod_reference_cache[ShortName] = mods = CreateAllMods().Cast<IMod>().ToArray();
return mods;
}