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:
parent
f44ba6a4c6
commit
955a0ff477
1 changed files with 19 additions and 17 deletions
|
@ -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 };
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue