You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
There is a host of functionality in the engine requiring looking up an AssetTypeAction object that best maps to a given class. The metric of 'best' is the AssetTypeAction whose SupportedClass is the closest to the given class in a hierarchy. The existing implementation searches through all AssetTypeActions (at time of writing, > 200) and queries each for their SupportedClass and then chooses the one whose SupportedClass is closest to the given class. The improvement here exploits that UClass is the type information of UObjects, and UObjects don't support multiple-inheritance (ie. only one SuperClass). Therefore we can walk the class hierarchy from the given Class up to find the best AssetTypeAction. This changes the linear search (with # of AssetTypeActions) to a nominal sub-linear search (with depth of inheritance). To be able to do that, a new map was added that associates a registered AssetTypeAction's SupportedClass with the AssetTypeAction's index in it's array. This lets us do a constant time lookup at the cost of a bit of memory. There is further room for improvement with the usage of UFactory's public member functions such as `GetDisplayName`, `GetMenuCategories` and similar which still necessitates this query. Opportunity exists in the NewAssetContextMenu and in the API of IAssetTools::GetNewAssetFactories to generate a more performance oriented data structure. There is also some opportunity to improve the construction of a FSoftClassPath from a UClass which can be fairly expensive. These all feed into the performance issue but ultimately this is the smallest change that provides the largest improvements at the lowest risk. Testing: Using debugger stepped through startup/shutdown of the editor. Artificially added duplicate registrations to check codepaths for adding AssetTypeActions that with same supported class Added unregisters to check codepaths for unregister. Need to be careful with editor as AssetTool module is removed very early on outside of the usual lifetime of modules in EngineLoop::Exit so most AssetTypeActions do not actually get deregistered. #jira UE-175345 #rb ronald.koppers #preflight 63ed3f277e76998e9a66a676 [CL 24253312 by logan buchy in ue5-main branch]