Closed hymerman closed 7 years ago
Yep, caching this should be reasonable. Rename AllSimpleTypesDerivingFrom to AllSimpleTypesDerivingFromInternal.
Then the cache is just
static Dictionary<Type, IEnumerable<Type>> cache = new Dictionary<Type, IEnumerable<Type>>();
public IEnumerable<Type> AllSimpleTypesDerivingFrom(Type t) {
IEnumerable<Type> result;
if (!cache.TryGetValue(t, out result)) {
result = AllSimpleTypesDerivingFromInternal(t);
cache[t] = result;
}
return result;
}
I'll try to get to this in a few days, but I'd be happy to accept a pull request :)
Thanks - I've done something similar to this locally and it's a great speed improvement, but I still don't know what happens with reloading assemblies - if you think it's ok though, that's good enough for me :) I'll cobble a PR together if I get time (and will say I'm doing so here so you don't waste time doing it yourself!).
I've done this and tweaked it a bit; I'll submit a PR later
The
TryEnsureScript
call insidefiSharedInstancePropertyEditor
callsfiSharedInstanceUtility.GetSerializableType
, which I'm finding is extremely slow, mostly because of theAssembly.GetTypesWithoutException
call which allocates a lot of memory, and iterating through the many, many types which costs a lot of CPU time.Is there some way to cache the results of e.g.
fiRuntimeReflectionUtility.AllSimpleTypesDerivingFrom
? I imagine the cache would need to be regenerated on any assembly reload but I'm not sure how to go about doing that. Any ideas?