mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-01-01 13:23:40 +01:00
GameConfig - Use ConcurrentDictionary for index cache
This commit is contained in:
parent
4953610505
commit
c4f8a09530
1 changed files with 5 additions and 7 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Concurrent;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
|
||||||
using Dalamud.Memory;
|
using Dalamud.Memory;
|
||||||
|
|
@ -15,9 +15,8 @@ namespace Dalamud.Game.Config;
|
||||||
public class GameConfigSection
|
public class GameConfigSection
|
||||||
{
|
{
|
||||||
private readonly Framework framework;
|
private readonly Framework framework;
|
||||||
private readonly Dictionary<string, uint> indexMap = new();
|
private readonly ConcurrentDictionary<string, uint> indexMap = new();
|
||||||
private readonly Dictionary<uint, string> nameMap = new();
|
private readonly ConcurrentDictionary<uint, object> enumMap = new();
|
||||||
private readonly Dictionary<uint, object> enumMap = new();
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Event which is fired when a game config option is changed within the section.
|
/// Event which is fired when a game config option is changed within the section.
|
||||||
|
|
@ -404,12 +403,12 @@ public class GameConfigSection
|
||||||
var name = MemoryHelper.ReadStringNullTerminated(new IntPtr(entry->Name));
|
var name = MemoryHelper.ReadStringNullTerminated(new IntPtr(entry->Name));
|
||||||
if (Enum.TryParse(typeof(TEnum), name, out enumObject))
|
if (Enum.TryParse(typeof(TEnum), name, out enumObject))
|
||||||
{
|
{
|
||||||
this.enumMap.Add(entry->Index, enumObject);
|
this.enumMap.TryAdd(entry->Index, enumObject);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
enumObject = null;
|
enumObject = null;
|
||||||
this.enumMap.Add(entry->Index, null);
|
this.enumMap.TryAdd(entry->Index, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -439,7 +438,6 @@ public class GameConfigSection
|
||||||
if (eName.Equals(name))
|
if (eName.Equals(name))
|
||||||
{
|
{
|
||||||
this.indexMap.TryAdd(name, i);
|
this.indexMap.TryAdd(name, i);
|
||||||
this.nameMap.TryAdd(i, name);
|
|
||||||
index = i;
|
index = i;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue