mirror of
https://github.com/tnodir/fort
synced 2024-11-15 08:35:08 +00:00
UI: IocContainer: Microoptimize
This commit is contained in:
parent
9a74a8225b
commit
8875a55015
@ -56,16 +56,18 @@ void IocContainer::autoDeleteAll()
|
||||
}
|
||||
}
|
||||
|
||||
void IocContainer::setUp(int typeId)
|
||||
IocService *IocContainer::setUp(int typeId)
|
||||
{
|
||||
const quint8 flags = m_objectFlags[typeId];
|
||||
if ((flags & (IsService | WasSetUp)) != IsService)
|
||||
return;
|
||||
IocService *obj = resolveService(typeId);
|
||||
|
||||
const quint8 flags = m_objectFlags[typeId];
|
||||
if ((flags & (IsService | WasSetUp)) == IsService) {
|
||||
m_objectFlags[typeId] = (flags | WasSetUp);
|
||||
|
||||
IocService *obj = resolveService(typeId);
|
||||
obj->setUp();
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
void IocContainer::tearDown(int typeId)
|
||||
|
@ -66,17 +66,16 @@ public:
|
||||
return static_cast<T *>(resolveService(getTypeId<T>()));
|
||||
}
|
||||
|
||||
void setUpAll();
|
||||
void tearDownAll();
|
||||
void autoDeleteAll();
|
||||
|
||||
template<class T>
|
||||
inline constexpr T *setUpDependency()
|
||||
{
|
||||
setUp(getTypeId<T>());
|
||||
return resolve<T>();
|
||||
return static_cast<T *>(setUp(getTypeId<T>()));
|
||||
}
|
||||
|
||||
void setUpAll();
|
||||
void tearDownAll();
|
||||
void autoDeleteAll();
|
||||
|
||||
bool pinToThread();
|
||||
|
||||
inline static IocContainer *getPinned()
|
||||
@ -101,7 +100,7 @@ private:
|
||||
return static_cast<IocService *>(resolveObject(typeId));
|
||||
}
|
||||
|
||||
void setUp(int typeId);
|
||||
IocService *setUp(int typeId);
|
||||
void tearDown(int typeId);
|
||||
void autoDelete(int typeId);
|
||||
|
||||
@ -124,9 +123,7 @@ constexpr auto IoCPinned = IocContainer::getPinned;
|
||||
template<class T>
|
||||
inline static T *IoC()
|
||||
{
|
||||
const IocContainer *container = IoCPinned();
|
||||
Q_ASSERT(container);
|
||||
return container->resolve<T>();
|
||||
return IoCPinned()->resolve<T>();
|
||||
}
|
||||
|
||||
#endif // IOCCONTAINER_H
|
||||
|
Loading…
Reference in New Issue
Block a user