缓存 UnityRenamePolicy::IsUnitySourceGeneratedAssemblyType的计算结果,优化性能
parent
14a6ddb661
commit
94b9b7ee2f
|
@ -126,7 +126,9 @@ namespace Obfuz.ObfusPasses.SymbolObfus.Policies
|
||||||
"OnCancel",
|
"OnCancel",
|
||||||
};
|
};
|
||||||
|
|
||||||
private bool IsUnitySourceGeneratedAssemblyType(TypeDef typeDef)
|
private readonly Dictionary<TypeDef, bool> _unitySourceGeneratedComputeCache = new Dictionary<TypeDef, bool>();
|
||||||
|
|
||||||
|
private bool ComputeIsUnitySourceGeneratedAssemblyType(TypeDef typeDef)
|
||||||
{
|
{
|
||||||
if (typeDef.Name.StartsWith("UnitySourceGeneratedAssemblyMonoScriptTypes_"))
|
if (typeDef.Name.StartsWith("UnitySourceGeneratedAssemblyMonoScriptTypes_"))
|
||||||
{
|
{
|
||||||
|
@ -155,6 +157,17 @@ namespace Obfuz.ObfusPasses.SymbolObfus.Policies
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool IsUnitySourceGeneratedAssemblyType(TypeDef typeDef)
|
||||||
|
{
|
||||||
|
if (_unitySourceGeneratedComputeCache.TryGetValue(typeDef, out var result))
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
result = ComputeIsUnitySourceGeneratedAssemblyType(typeDef);
|
||||||
|
_unitySourceGeneratedComputeCache.Add(typeDef, result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
private bool DoesDeclaringTypeDisableAllMemberRenaming(TypeDef typeDef)
|
private bool DoesDeclaringTypeDisableAllMemberRenaming(TypeDef typeDef)
|
||||||
{
|
{
|
||||||
if (typeDef.IsEnum && MetaUtil.HasBlackboardEnumAttribute(typeDef))
|
if (typeDef.IsEnum && MetaUtil.HasBlackboardEnumAttribute(typeDef))
|
||||||
|
|
Loading…
Reference in New Issue