Remove some unnecessary allocations

This commit is contained in:
cvium
2021-05-24 00:30:41 +02:00
parent db9d3b8653
commit 42a2cc1747
43 changed files with 1095 additions and 906 deletions

View File

@@ -28,19 +28,9 @@ namespace Emby.Server.Implementations.Data
throw new ArgumentNullException(nameof(typeName));
}
return _typeMap.GetOrAdd(typeName, LookupType);
}
/// <summary>
/// Lookups the type.
/// </summary>
/// <param name="typeName">Name of the type.</param>
/// <returns>Type.</returns>
private Type? LookupType(string typeName)
{
return AppDomain.CurrentDomain.GetAssemblies()
.Select(a => a.GetType(typeName))
.FirstOrDefault(t => t != null);
return _typeMap.GetOrAdd(typeName, k => AppDomain.CurrentDomain.GetAssemblies()
.Select(a => a.GetType(k))
.FirstOrDefault(t => t != null));
}
}
}