Model: Eliminate no-longer needed thread lock in CAD

This commit is contained in:
Katy Coe
2020-12-30 09:16:25 +01:00
parent a0cd61bb13
commit 7c65d2c741

View File

@@ -64,14 +64,8 @@ namespace Il2CppInspector.Reflection
} }
} }
private static readonly object gcaLock = new object(); private static IList<CustomAttributeData> getCustomAttributes(Assembly asm, uint token, int customAttributeIndex) =>
private static IList<CustomAttributeData> getCustomAttributes(Assembly asm, uint token, int customAttributeIndex) { getCustomAttributes(asm, asm.Model.GetCustomAttributeIndex(asm, token, customAttributeIndex)).ToList();
// Force the generation of the collection to be thread-safe
// Convert the result into a list for thread-safe enumeration
lock (gcaLock) {
return getCustomAttributes(asm, asm.Model.GetCustomAttributeIndex(asm, token, customAttributeIndex)).ToList();
}
}
public static IList<CustomAttributeData> GetCustomAttributes(Assembly asm) => getCustomAttributes(asm, asm.AssemblyDefinition.token, asm.AssemblyDefinition.customAttributeIndex); public static IList<CustomAttributeData> GetCustomAttributes(Assembly asm) => getCustomAttributes(asm, asm.AssemblyDefinition.token, asm.AssemblyDefinition.customAttributeIndex);
public static IList<CustomAttributeData> GetCustomAttributes(EventInfo evt) => getCustomAttributes(evt.Assembly, evt.Definition.token, evt.Definition.customAttributeIndex); public static IList<CustomAttributeData> GetCustomAttributes(EventInfo evt) => getCustomAttributes(evt.Assembly, evt.Definition.token, evt.Definition.customAttributeIndex);