diff options
author | Lenny Maiorani <lenny@colorado.edu> | 2021-04-22 15:19:28 -0600 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-04-23 08:28:25 +0200 |
commit | 4378d36f6701e0f4efe71ff1a301e3cd0776d5bf (patch) | |
tree | a8a5ca34c04e171226db537c8bd0a6fc475501e5 /AK | |
parent | fcd3b9a0df3efb0f1e9187f7e451715d2c7aeea5 (diff) | |
download | serenity-4378d36f6701e0f4efe71ff1a301e3cd0776d5bf.zip |
AK: Remove virtual destructors from non-virtual classes
Problem:
- Some classes have `virtual` destructors despite not having any
virtual functions. This causes the classes to have a v-table and
perform extra jumps at destruction time when there is no need.
Solution:
- Remove `virtual` keyword from destructors where there are no other
virtual functions.
- Remove the destructor completely when the default destructor can be
used.
Diffstat (limited to 'AK')
-rw-r--r-- | AK/IntrusiveRedBlackTree.h | 2 | ||||
-rw-r--r-- | AK/RedBlackTree.h | 4 |
2 files changed, 2 insertions, 4 deletions
diff --git a/AK/IntrusiveRedBlackTree.h b/AK/IntrusiveRedBlackTree.h index 1a13e45aec..e2ff1c2288 100644 --- a/AK/IntrusiveRedBlackTree.h +++ b/AK/IntrusiveRedBlackTree.h @@ -17,7 +17,7 @@ template<Integral K, typename V, IntrusiveRedBlackTreeNode<K> V::*member> class IntrusiveRedBlackTree : public BaseRedBlackTree<K> { public: IntrusiveRedBlackTree() = default; - virtual ~IntrusiveRedBlackTree() override + ~IntrusiveRedBlackTree() { clear(); } diff --git a/AK/RedBlackTree.h b/AK/RedBlackTree.h index dbfebbad27..ac6db5619e 100644 --- a/AK/RedBlackTree.h +++ b/AK/RedBlackTree.h @@ -33,12 +33,10 @@ public: : key(key) { } - virtual ~Node() {}; }; protected: BaseRedBlackTree() = default; // These are protected to ensure no one instantiates the leaky base red black tree directly - virtual ~BaseRedBlackTree() {}; void rotate_left(Node* subtree_root) { @@ -418,7 +416,7 @@ template<Integral K, typename V> class RedBlackTree : public BaseRedBlackTree<K> { public: RedBlackTree() = default; - virtual ~RedBlackTree() override + ~RedBlackTree() { clear(); } |