diff options
author | Marius Ungureanu <marius.ungureanu@xamarin.com> | 2017-05-26 22:35:13 +0300 |
---|---|---|
committer | Marius Ungureanu <marius.ungureanu@xamarin.com> | 2017-05-26 22:35:35 +0300 |
commit | 6ac710889580919bef6381c15f846716cab52206 (patch) | |
tree | 66ed3f77d8b36a31240744f6ea205e5799bbcad8 /Mono.Addins/Mono.Addins.Database | |
parent | 1f78f03244c2fb280760ff3869e09777dbe676c7 (diff) |
[Perf] Optimize assembly scanning by not doing unnecessary work
Making this item a lazy will make condition attributes only queried when they have to be. Empirical testing shows 1 second time spent (from 2s down to 1s) on 39 assembly files by halving the number of calls.
Diffstat (limited to 'Mono.Addins/Mono.Addins.Database')
-rw-r--r-- | Mono.Addins/Mono.Addins.Database/AddinScanner.cs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Mono.Addins/Mono.Addins.Database/AddinScanner.cs b/Mono.Addins/Mono.Addins.Database/AddinScanner.cs index 44cacd8..1cf559c 100644 --- a/Mono.Addins/Mono.Addins.Database/AddinScanner.cs +++ b/Mono.Addins/Mono.Addins.Database/AddinScanner.cs @@ -930,7 +930,7 @@ namespace Mono.Addins.Database //condition attributes apply independently but identically to all extension attributes on this node //depending on ordering is too messy due to inheritance etc - var conditionAtts = reflector.GetRawCustomAttributes (t, typeof (CustomConditionAttribute), false); + var conditionAtts = new Lazy<List<CustomAttribute>> (() => reflector.GetRawCustomAttributes (t, typeof (CustomConditionAttribute), false)); // Look for extensions @@ -956,7 +956,7 @@ namespace Mono.Addins.Database path = eatt.Path; } - ExtensionNodeDescription elem = AddConditionedExtensionNode (module, path, nodeName, conditionAtts); + ExtensionNodeDescription elem = AddConditionedExtensionNode (module, path, nodeName, conditionAtts.Value); nodes [path] = elem; uniqueNode = elem; @@ -1021,7 +1021,7 @@ namespace Mono.Addins.Database else { // Look for custom extension attribtues foreach (CustomAttribute att in reflector.GetRawCustomAttributes (t, typeof(CustomExtensionAttribute), false)) { - ExtensionNodeDescription elem = AddCustomAttributeExtension (module, att, "Type", conditionAtts); + ExtensionNodeDescription elem = AddCustomAttributeExtension (module, att, "Type", conditionAtts.Value); elem.SetAttribute ("type", typeFullName); if (string.IsNullOrEmpty (elem.GetAttribute ("id"))) elem.SetAttribute ("id", typeFullName); |