You don't need the recursion in the ReuseScope.Hierarchy case. Make the following change will result in a modest performance improvement
case ReuseScope.Hierarchy:
{
if (entry.Instance == null)
{
// if (entry.Container != this)
// {
// return entry.Container.ResolveImpl<TService, TFunc>(name, invoker, throwIfMissing);
// }
// else
// {
// var instance = CreateInstance<TService, TFunc>(entry, invoker);
// entry.Instance = instance;
// InitializeInstance(entry, instance);
// }
var instance = entry.Container.CreateInstance<TService, TFunc>(entry, invoker);
entry.Instance = instance;
InitializeInstance(entry, instance);
}
return (TService)entry.Instance;
}