It's very common for an assembly to have only one module, in which case we can avoid unnecessary allocations and copies in Assembly.GetTypes() and Assembly.DefinedTypes.
public virtual Type[] GetTypes()
{
Module[] m = GetModules(false);
+ if (m.Length == 1)
+ {
+ return m[0].GetTypes();
+ }
int finalLength = 0;
Type[][] moduleTypes = new Type[m.Length][];
{
get
{
- List<RuntimeType> rtTypes = new List<RuntimeType>();
-
RuntimeModule[] modules = GetModulesInternal(true, false);
+ if (modules.Length == 1)
+ {
+ return modules[0].GetDefinedTypes();
+ }
+
+ List<RuntimeType> rtTypes = new List<RuntimeType>();
for (int i = 0; i < modules.Length; i++)
{