mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 19:22:54 +08:00
Merge pull request #15736 from peppy/ruleset-use-short-name
Use `Ruleset`'s `ShortName` for mod caching purposes
This commit is contained in:
commit
d9db3b9e78
@ -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,12 @@ namespace osu.Game.Rulesets
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!(RulesetInfo.ID is int id))
|
||||
// Is the case for many test usages.
|
||||
if (string.IsNullOrEmpty(ShortName))
|
||||
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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user