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 { };
}
template<typename T>
class Retainable {
class RetainableBase {
public:
void retain()
{
@ -38,6 +37,24 @@ public:
++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()
{
ASSERT(m_retain_count);
@ -49,21 +66,6 @@ public:
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 };
};
}