mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
chore: use ConcurrentDictionary in SigScanner
This commit is contained in:
parent
7760457dc5
commit
cf13e4f69d
1 changed files with 7 additions and 12 deletions
|
|
@ -1,11 +1,12 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Concurrent;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Windows.Forms;
|
|
||||||
using Dalamud.IoC;
|
using Dalamud.IoC;
|
||||||
using Dalamud.IoC.Internal;
|
using Dalamud.IoC.Internal;
|
||||||
using Dalamud.Utility.Timing;
|
using Dalamud.Utility.Timing;
|
||||||
|
|
@ -27,7 +28,7 @@ namespace Dalamud.Game
|
||||||
private IntPtr moduleCopyPtr;
|
private IntPtr moduleCopyPtr;
|
||||||
private long moduleCopyOffset;
|
private long moduleCopyOffset;
|
||||||
|
|
||||||
private Dictionary<string, long>? textCache;
|
private ConcurrentDictionary<string, long>? textCache;
|
||||||
|
|
||||||
[ServiceManager.ServiceConstructor]
|
[ServiceManager.ServiceConstructor]
|
||||||
private SigScanner(DalamudStartInfo startInfo)
|
private SigScanner(DalamudStartInfo startInfo)
|
||||||
|
|
@ -342,12 +343,9 @@ namespace Dalamud.Game
|
||||||
{
|
{
|
||||||
if (this.textCache != null)
|
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)
|
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;
|
return scanRet;
|
||||||
|
|
@ -563,7 +558,7 @@ namespace Dalamud.Game
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.textCache = JsonConvert.DeserializeObject<Dictionary<string, long>>(File.ReadAllText(this.cacheFile.FullName)) ?? new Dictionary<string, long>();
|
this.textCache = JsonConvert.DeserializeObject<ConcurrentDictionary<string, long>>(File.ReadAllText(this.cacheFile.FullName)) ?? new ConcurrentDictionary<string, long>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue