From 955a0ff4774c25e39b89030be902f90d2e9f3162 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 16 Mar 2019 12:47:19 +0100 Subject: [PATCH] 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. --- AK/Retainable.h | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/AK/Retainable.h b/AK/Retainable.h index b14ca56a24..ced4399ffb 100644 --- a/AK/Retainable.h +++ b/AK/Retainable.h @@ -29,8 +29,7 @@ constexpr auto call_one_retain_left_if_present(...) -> FalseType return { }; } -template -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 +class Retainable : public RetainableBase { +public: void release() { ASSERT(m_retain_count); @@ -49,21 +66,6 @@ public: call_one_retain_left_if_present(static_cast(this)); } } - - int retain_count() const - { - return m_retain_count; - } - -protected: - Retainable() { } - ~Retainable() - { - ASSERT(!m_retain_count); - } - -private: - int m_retain_count { 1 }; }; }