Skip to content
This repository was archived by the owner on Nov 30, 2020. It is now read-only.

Commit e949822

Browse files
committed
Cached the result of GetAllAssemblyTypes per domain reload
Speeds up domain reload
1 parent c6ac675 commit e949822

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

PostProcessing/Runtime/Utils/RuntimeUtilities.cs

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -502,20 +502,27 @@ public static Matrix4x4 GenerateJitteredProjectionMatrixFromOriginal(PostProcess
502502

503503
#region Reflection
504504

505+
static IEnumerable<Type> m_AssemblyTypes;
506+
505507
public static IEnumerable<Type> GetAllAssemblyTypes()
506508
{
507-
return AppDomain.CurrentDomain.GetAssemblies()
508-
.SelectMany(t =>
509-
{
510-
// Ugly hack to handle mis-versioned dlls
511-
var innerTypes = new Type[0];
512-
try
509+
if (m_AssemblyTypes == null)
510+
{
511+
m_AssemblyTypes = AppDomain.CurrentDomain.GetAssemblies()
512+
.SelectMany(t =>
513513
{
514-
innerTypes = t.GetTypes();
515-
}
516-
catch {}
517-
return innerTypes;
518-
});
514+
// Ugly hack to handle mis-versioned dlls
515+
var innerTypes = new Type[0];
516+
try
517+
{
518+
innerTypes = t.GetTypes();
519+
}
520+
catch { }
521+
return innerTypes;
522+
});
523+
}
524+
525+
return m_AssemblyTypes;
519526
}
520527

521528
// Quick extension method to get the first attribute of type T on a given Type

0 commit comments

Comments
 (0)