feat: add type cache to increase performance.
This commit is contained in:
parent
3f1a1e1a78
commit
0059fc43e1
1 changed files with 7 additions and 2 deletions
|
@ -113,7 +113,7 @@ namespace Jellyfin.Plugin.SmartPlaylist.Lisp {
|
||||||
|
|
||||||
public class Builtins : Dictionary<string, Function> {
|
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() {
|
public Builtins() : base() {
|
||||||
this["atom"] = _atom;
|
this["atom"] = _atom;
|
||||||
|
@ -261,12 +261,17 @@ namespace Jellyfin.Plugin.SmartPlaylist.Lisp {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Type? GetType(string name) {
|
private static Type? GetType(string name) {
|
||||||
return Type.GetType(
|
if (ResolvedTypes.ContainsKey(name)) {
|
||||||
|
return ResolvedTypes[name];
|
||||||
|
}
|
||||||
|
var t = Type.GetType(
|
||||||
name,
|
name,
|
||||||
(name) => { return AppDomain.CurrentDomain.GetAssemblies().Where(z => (z.FullName != null) && z.FullName.StartsWith(name.FullName)).FirstOrDefault(); },
|
(name) => { return AppDomain.CurrentDomain.GetAssemblies().Where(z => (z.FullName != null) && z.FullName.StartsWith(name.FullName)).FirstOrDefault(); },
|
||||||
null,
|
null,
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
ResolvedTypes[name] = t;
|
||||||
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Expression _invoke_generic(IEnumerable<Expression> args) {
|
private static Expression _invoke_generic(IEnumerable<Expression> args) {
|
||||||
|
|
Loading…
Reference in a new issue