Optimize C# types searching with typename

This commit is contained in:
Wojtek Figat
2022-04-13 19:48:39 +02:00
parent 738e7d2516
commit 017492dbfa
2 changed files with 18 additions and 51 deletions

View File

@@ -233,18 +233,7 @@ namespace FlaxEditor.Scripting
{
if (string.IsNullOrEmpty(typeName))
return null;
var assemblies = AppDomain.CurrentDomain.GetAssemblies();
for (int i = 0; i < assemblies.Length; i++)
{
var assembly = assemblies[i];
if (assembly != null)
{
var type = assembly.GetType(typeName);
if (type != null)
return type;
}
}
return null;
return Type.GetType(typeName);
}
/// <summary>
@@ -258,18 +247,10 @@ namespace FlaxEditor.Scripting
return ScriptType.Null;
// C#/C++ types
var assemblies = AppDomain.CurrentDomain.GetAssemblies();
for (int i = 0; i < assemblies.Length; i++)
{
var assembly = assemblies[i];
if (assembly != null)
{
var type = assembly.GetType(typeName);
if (type != null)
{
return new ScriptType(type);
}
}
var type = Type.GetType(typeName);
if (type != null)
return new ScriptType(type);
}
// Custom types
@@ -277,9 +258,7 @@ namespace FlaxEditor.Scripting
{
var type = customTypesInfo.GetType(typeName);
if (type)
{
return type;
}
}
return ScriptType.Null;