diff --git a/Dalamud/Game/SigScanner.cs b/Dalamud/Game/SigScanner.cs index 7254e41e2..46418384e 100644 --- a/Dalamud/Game/SigScanner.cs +++ b/Dalamud/Game/SigScanner.cs @@ -1,11 +1,12 @@ using System; +using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -using System.Windows.Forms; + using Dalamud.IoC; using Dalamud.IoC.Internal; using Dalamud.Utility.Timing; @@ -27,7 +28,7 @@ namespace Dalamud.Game private IntPtr moduleCopyPtr; private long moduleCopyOffset; - private Dictionary? textCache; + private ConcurrentDictionary? textCache; [ServiceManager.ServiceConstructor] private SigScanner(DalamudStartInfo startInfo) @@ -342,12 +343,9 @@ namespace Dalamud.Game { if (this.textCache != null) { - lock (this.textCache) + if (this.textCache.TryGetValue(signature, out var address)) { - if (this.textCache.TryGetValue(signature, out var address)) - { - return new IntPtr(address + this.Module.BaseAddress.ToInt64()); - } + return new IntPtr(address + this.Module.BaseAddress.ToInt64()); } } @@ -364,10 +362,7 @@ namespace Dalamud.Game if (this.textCache != null) { - lock (this.textCache) - { - this.textCache[signature] = scanRet.ToInt64() - this.Module.BaseAddress.ToInt64(); - } + this.textCache[signature] = scanRet.ToInt64() - this.Module.BaseAddress.ToInt64(); } return scanRet; @@ -563,7 +558,7 @@ namespace Dalamud.Game return; } - this.textCache = JsonConvert.DeserializeObject>(File.ReadAllText(this.cacheFile.FullName)) ?? new Dictionary(); + this.textCache = JsonConvert.DeserializeObject>(File.ReadAllText(this.cacheFile.FullName)) ?? new ConcurrentDictionary(); } } }