From 0059fc43e171b68921f47ac1381e697b9af42b29 Mon Sep 17 00:00:00 2001 From: redxef Date: Tue, 17 Dec 2024 18:18:26 +0100 Subject: [PATCH] feat: add type cache to increase performance. --- Jellyfin.Plugin.SmartPlaylist/Lisp/Interpreter.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Jellyfin.Plugin.SmartPlaylist/Lisp/Interpreter.cs b/Jellyfin.Plugin.SmartPlaylist/Lisp/Interpreter.cs index df40feb..265ecd5 100644 --- a/Jellyfin.Plugin.SmartPlaylist/Lisp/Interpreter.cs +++ b/Jellyfin.Plugin.SmartPlaylist/Lisp/Interpreter.cs @@ -113,7 +113,7 @@ namespace Jellyfin.Plugin.SmartPlaylist.Lisp { public class Builtins : Dictionary { - private static Dictionary AssemblyMapping = new Dictionary(); + private static Dictionary ResolvedTypes = new Dictionary(); public Builtins() : base() { this["atom"] = _atom; @@ -261,12 +261,17 @@ namespace Jellyfin.Plugin.SmartPlaylist.Lisp { } private static Type? GetType(string name) { - return Type.GetType( + if (ResolvedTypes.ContainsKey(name)) { + return ResolvedTypes[name]; + } + var t = Type.GetType( name, (name) => { return AppDomain.CurrentDomain.GetAssemblies().Where(z => (z.FullName != null) && z.FullName.StartsWith(name.FullName)).FirstOrDefault(); }, null, true ); + ResolvedTypes[name] = t; + return t; } private static Expression _invoke_generic(IEnumerable args) {