Skip to content

Commit 5159788

Browse files
committed
refactor: Change storage to Concurrent Stack for thread safety
1 parent 0c53677 commit 5159788

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/UnityDebuggerAssistant/Patches/Exception.cs

+3-5
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
using System.Collections.Generic;
44
using HarmonyLib;
55
using UnityDebuggerAssistant.Utils;
6+
using System.Collections.Concurrent;
67

78
namespace UnityDebuggerAssistant.Patches;
89
[HarmonyPatch]
910
public static class ExceptionConstructorPatch
1011
{
1112

12-
internal static readonly List<Exception> Storage = [];
13+
internal static readonly ConcurrentStack<Exception> Storage = [];
1314

1415
static IEnumerable<MethodBase> TargetMethods()
1516
{
@@ -18,10 +19,7 @@ static IEnumerable<MethodBase> TargetMethods()
1819

1920
static void Postfix(Exception __instance)
2021
{
21-
if (Storage.Contains(__instance))
22-
return;
23-
24-
Storage.Add(__instance);
22+
Storage.Push(__instance);
2523
}
2624
}
2725
internal static class ExceptionProcessor

0 commit comments

Comments
 (0)