Switch to a new API introduced in Cecil added new API to get all the attributes in an assembly, without having to traverse (and load) every type and member. This makes mtouch significantly faster when computing the list of referenced assemblies, which is noticable when mtouch later determines nothing else needs to be done (because nothing changed). A few tests show that mtouch is now approximately twice as fast: * A customer test project goes from 2s to 1s. * A simple test app goes from 1.3s to 0.6. https://bugzilla.xamarin.com/show_bug.cgi?id=49087
This commit is contained in:
Родитель
00c4d892dc
Коммит
3b310b71eb
|
@ -305,34 +305,8 @@ namespace Xamarin.Bundler
|
|||
GetCustomAttributeReferences (assembly, assemblies, exceptions);
|
||||
GetCustomAttributeReferences (main, assemblies, exceptions);
|
||||
if (main.HasTypes) {
|
||||
foreach (var t in main.Types) {
|
||||
GetTypeReferences (t, assemblies, exceptions);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GetTypeReferences (TypeDefinition type, HashSet<string> assemblies, List<Exception> exceptions)
|
||||
{
|
||||
GetCustomAttributeReferences (type, assemblies, exceptions);
|
||||
if (type.HasEvents) {
|
||||
foreach (var e in type.Events)
|
||||
GetCustomAttributeReferences (e, assemblies, exceptions);
|
||||
}
|
||||
if (type.HasFields) {
|
||||
foreach (var f in type.Fields)
|
||||
GetCustomAttributeReferences (f, assemblies, exceptions);
|
||||
}
|
||||
if (type.HasMethods) {
|
||||
foreach (var m in type.Methods)
|
||||
GetCustomAttributeReferences (m, assemblies, exceptions);
|
||||
}
|
||||
if (type.HasProperties) {
|
||||
foreach (var p in type.Properties)
|
||||
GetCustomAttributeReferences (p, assemblies, exceptions);
|
||||
}
|
||||
if (type.HasNestedTypes) {
|
||||
foreach (var nt in type.NestedTypes)
|
||||
GetTypeReferences (nt, assemblies, exceptions);
|
||||
foreach (var ca in main.GetCustomAttributes ())
|
||||
GetCustomAttributeReferences (ca, assemblies, exceptions);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -340,7 +314,12 @@ namespace Xamarin.Bundler
|
|||
{
|
||||
if (!cap.HasCustomAttributes)
|
||||
return;
|
||||
foreach (var ca in cap.CustomAttributes) {
|
||||
foreach (var ca in cap.CustomAttributes)
|
||||
GetCustomAttributeReferences (ca, assemblies, exceptions);
|
||||
}
|
||||
|
||||
void GetCustomAttributeReferences (CustomAttribute ca, HashSet<string> assemblies, List<Exception> exceptions)
|
||||
{
|
||||
if (ca.HasConstructorArguments) {
|
||||
foreach (var arg in ca.ConstructorArguments)
|
||||
GetCustomAttributeArgumentReference (arg, assemblies, exceptions);
|
||||
|
@ -354,7 +333,6 @@ namespace Xamarin.Bundler
|
|||
GetCustomAttributeArgumentReference (arg.Argument, assemblies, exceptions);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GetCustomAttributeArgumentReference (CustomAttributeArgument arg, HashSet<string> assemblies, List<Exception> exceptions)
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче