From 5690707c7318ac764c4a5277828a3f8bf626a610 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Mon, 23 Sep 2024 21:01:04 +0200 Subject: [PATCH] Optimize generic `GetActors`/`GetScripts` on basic type --- Source/Engine/Level/Level.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Source/Engine/Level/Level.cs b/Source/Engine/Level/Level.cs index 4ba9ace8b..ae596e794 100644 --- a/Source/Engine/Level/Level.cs +++ b/Source/Engine/Level/Level.cs @@ -109,6 +109,8 @@ namespace FlaxEngine public static T[] GetScripts() where T : Script { var scripts = GetScripts(typeof(T)); + if (typeof(T) == typeof(Script)) + return (T[])scripts; if (scripts.Length == 0) return Array.Empty(); var result = new T[scripts.Length]; @@ -126,6 +128,8 @@ namespace FlaxEngine public static T[] GetActors(bool activeOnly = false) where T : Actor { var actors = GetActors(typeof(T), activeOnly); + if (typeof(T) == typeof(Actor)) + return (T[])actors; if (actors.Length == 0) return Array.Empty(); var result = new T[actors.Length];