feat: add type cache to increase performance.

This commit is contained in:
redxef 2024-12-17 18:18:26 +01:00
parent 3f1a1e1a78
commit 0059fc43e1
Signed by: redxef
GPG key ID: 7DAC3AA211CBD921

View file

@ -113,7 +113,7 @@ namespace Jellyfin.Plugin.SmartPlaylist.Lisp {
public class Builtins : Dictionary<string, Function> {
private static Dictionary<string, Assembly> AssemblyMapping = new Dictionary<string, Assembly>();
private static Dictionary<string, Type?> ResolvedTypes = new Dictionary<string, Type?>();
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<Expression> args) {