mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 00:50:22 +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
Notes:
sideshowbarker
2024-07-19 15:01:57 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/955a0ff4774
1 changed files with 19 additions and 17 deletions
|
@ -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 };
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue