mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 11:07:45 +00:00
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.
This commit is contained in:
parent
fcd3b9a0df
commit
4378d36f67
2 changed files with 2 additions and 4 deletions
|
@ -17,7 +17,7 @@ template<Integral K, typename V, IntrusiveRedBlackTreeNode<K> V::*member>
|
||||||
class IntrusiveRedBlackTree : public BaseRedBlackTree<K> {
|
class IntrusiveRedBlackTree : public BaseRedBlackTree<K> {
|
||||||
public:
|
public:
|
||||||
IntrusiveRedBlackTree() = default;
|
IntrusiveRedBlackTree() = default;
|
||||||
virtual ~IntrusiveRedBlackTree() override
|
~IntrusiveRedBlackTree()
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,12 +33,10 @@ public:
|
||||||
: key(key)
|
: key(key)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
virtual ~Node() {};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
BaseRedBlackTree() = default; // These are protected to ensure no one instantiates the leaky base red black tree directly
|
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)
|
void rotate_left(Node* subtree_root)
|
||||||
{
|
{
|
||||||
|
@ -418,7 +416,7 @@ template<Integral K, typename V>
|
||||||
class RedBlackTree : public BaseRedBlackTree<K> {
|
class RedBlackTree : public BaseRedBlackTree<K> {
|
||||||
public:
|
public:
|
||||||
RedBlackTree() = default;
|
RedBlackTree() = default;
|
||||||
virtual ~RedBlackTree() override
|
~RedBlackTree()
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue