diff --git a/Celeste.Mod.mm/Mod/Everest/Extensions.cs b/Celeste.Mod.mm/Mod/Everest/Extensions.cs index 4f914bbc2..32276ac26 100644 --- a/Celeste.Mod.mm/Mod/Everest/Extensions.cs +++ b/Celeste.Mod.mm/Mod/Everest/Extensions.cs @@ -335,8 +335,15 @@ public static bool IsDown(this TouchLocationState state) public static bool IsUp(this TouchLocationState state) => state == TouchLocationState.Released || state == TouchLocationState.Invalid; + [ThreadStatic] + private static HashSet _SafeTypes; public static bool IsSafe(this Type type) { + _SafeTypes ??= new HashSet(); + try { + if (_SafeTypes.Contains(type.AssemblyQualifiedName)) + return true; + // "Probe" the type _ = type.Name; _ = type.Assembly.FullName; @@ -348,6 +355,7 @@ public static bool IsSafe(this Type type) { if (!type.BaseType?.IsSafe() ?? false) return false; + _SafeTypes.Add(type.AssemblyQualifiedName); return true; } catch { return false;