mirror of https://github.com/AxioDL/metaforce.git
CFactoryMgr: std::move function instances in AddFactory()
std::function is allowed to allocate on the heap, so this potentially prevents unnecessary allocations. We can also use insert_or_assign() to prevent unnecessary default initialization of std::function that immediately get overridden.
This commit is contained in:
parent
d93df18a37
commit
34eb507a9d
|
@ -21,8 +21,8 @@ public:
|
||||||
bool CanMakeMemory(const urde::SObjectTag& tag) const;
|
bool CanMakeMemory(const urde::SObjectTag& tag) const;
|
||||||
CFactoryFnReturn MakeObjectFromMemory(const SObjectTag& tag, std::unique_ptr<u8[]>&& buf, int size, bool compressed,
|
CFactoryFnReturn MakeObjectFromMemory(const SObjectTag& tag, std::unique_ptr<u8[]>&& buf, int size, bool compressed,
|
||||||
const CVParamTransfer& paramXfer, CObjectReference* selfRef);
|
const CVParamTransfer& paramXfer, CObjectReference* selfRef);
|
||||||
void AddFactory(FourCC key, FFactoryFunc func) { m_factories[key] = func; }
|
void AddFactory(FourCC key, FFactoryFunc func) { m_factories.insert_or_assign(key, std::move(func)); }
|
||||||
void AddFactory(FourCC key, FMemFactoryFunc func) { m_memFactories[key] = func; }
|
void AddFactory(FourCC key, FMemFactoryFunc func) { m_memFactories.insert_or_assign(key, std::move(func)); }
|
||||||
|
|
||||||
enum class ETypeTable : u8 {
|
enum class ETypeTable : u8 {
|
||||||
CLSN,
|
CLSN,
|
||||||
|
|
Loading…
Reference in New Issue