1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 04:37:34 +00:00

AK: Reduce template bloat by hoisting non-typed parts of Retainable.

This is a bit of an old school hack, but it does remove a whole bunch of
generated symbols.
This commit is contained in:
Andreas Kling 2019-03-16 12:47:19 +01:00
parent f44ba6a4c6
commit 955a0ff477

View file

@ -29,8 +29,7 @@ constexpr auto call_one_retain_left_if_present(...) -> FalseType
return { }; return { };
} }
template<typename T> class RetainableBase {
class Retainable {
public: public:
void retain() void retain()
{ {
@ -38,6 +37,24 @@ public:
++m_retain_count; ++m_retain_count;
} }
int retain_count() const
{
return m_retain_count;
}
protected:
RetainableBase() { }
~RetainableBase()
{
ASSERT(!m_retain_count);
}
int m_retain_count { 1 };
};
template<typename T>
class Retainable : public RetainableBase {
public:
void release() void release()
{ {
ASSERT(m_retain_count); ASSERT(m_retain_count);
@ -49,21 +66,6 @@ public:
call_one_retain_left_if_present(static_cast<T*>(this)); call_one_retain_left_if_present(static_cast<T*>(this));
} }
} }
int retain_count() const
{
return m_retain_count;
}
protected:
Retainable() { }
~Retainable()
{
ASSERT(!m_retain_count);
}
private:
int m_retain_count { 1 };
}; };
} }