From c192c303d22a0b4ad698f5ad032527e3f86fbbbf Mon Sep 17 00:00:00 2001 From: Brian Gianforcaro Date: Wed, 15 Sep 2021 23:20:31 -0700 Subject: [PATCH] AK: Use default constructor/destructor instead of declaring an empty one Default implementations allow for more optimizations. See: https://pvs-studio.com/en/docs/warnings/v832/ --- AK/CircularQueue.h | 4 +--- AK/DistinctNumeric.h | 4 +--- AK/FixedArray.h | 2 +- AK/NonnullPtrVector.h | 4 +--- AK/RedBlackTree.h | 2 +- AK/UUID.cpp | 3 --- AK/UUID.h | 2 +- AK/Variant.h | 2 +- 8 files changed, 7 insertions(+), 16 deletions(-) diff --git a/AK/CircularQueue.h b/AK/CircularQueue.h index e0a68c87858..e7ec5463b2b 100644 --- a/AK/CircularQueue.h +++ b/AK/CircularQueue.h @@ -17,9 +17,7 @@ class CircularQueue { friend CircularDuplexStream; public: - CircularQueue() - { - } + CircularQueue() = default; ~CircularQueue() { diff --git a/AK/DistinctNumeric.h b/AK/DistinctNumeric.h index f6c2c67dbe0..8a5321143aa 100644 --- a/AK/DistinctNumeric.h +++ b/AK/DistinctNumeric.h @@ -52,9 +52,7 @@ class DistinctNumeric { using Self = DistinctNumeric; public: - constexpr DistinctNumeric() - { - } + constexpr DistinctNumeric() = default; constexpr DistinctNumeric(T value) : m_value { value } diff --git a/AK/FixedArray.h b/AK/FixedArray.h index c2d22512caa..d2a631fdd09 100644 --- a/AK/FixedArray.h +++ b/AK/FixedArray.h @@ -15,7 +15,7 @@ namespace AK { template class FixedArray { public: - FixedArray() { } + FixedArray() = default; explicit FixedArray(size_t size) : m_size(size) { diff --git a/AK/NonnullPtrVector.h b/AK/NonnullPtrVector.h index 5917dbd940b..37250191153 100644 --- a/AK/NonnullPtrVector.h +++ b/AK/NonnullPtrVector.h @@ -16,9 +16,7 @@ class NonnullPtrVector : public Vector { using Base = Vector; public: - NonnullPtrVector() - { - } + NonnullPtrVector() = default; NonnullPtrVector(Vector&& other) : Base(static_cast(other)) diff --git a/AK/RedBlackTree.h b/AK/RedBlackTree.h index b9ae98adfed..d81a14993a5 100644 --- a/AK/RedBlackTree.h +++ b/AK/RedBlackTree.h @@ -46,7 +46,7 @@ public: protected: BaseRedBlackTree() = default; // These are protected to ensure no one instantiates the leaky base red black tree directly - virtual ~BaseRedBlackTree() {}; + virtual ~BaseRedBlackTree() = default; void rotate_left(Node* subtree_root) { diff --git a/AK/UUID.cpp b/AK/UUID.cpp index 1234c29ad3a..cc87d7adca3 100644 --- a/AK/UUID.cpp +++ b/AK/UUID.cpp @@ -10,9 +10,6 @@ #include namespace AK { -UUID::UUID() -{ -} UUID::UUID(Array uuid_buffer) { diff --git a/AK/UUID.h b/AK/UUID.h index f547deb3d3e..fba7da8bdd5 100644 --- a/AK/UUID.h +++ b/AK/UUID.h @@ -15,7 +15,7 @@ namespace AK { class UUID { public: - UUID(); + UUID() = default; UUID(Array uuid_buffer); UUID(const StringView&); ~UUID() = default; diff --git a/AK/Variant.h b/AK/Variant.h index 287e7173238..f757e2a3acd 100644 --- a/AK/Variant.h +++ b/AK/Variant.h @@ -116,7 +116,7 @@ struct VariantConstructors { internal_cast().set(t, VariantNoClearTag {}); } - ALWAYS_INLINE VariantConstructors() { } + ALWAYS_INLINE VariantConstructors() = default; private: [[nodiscard]] ALWAYS_INLINE Base& internal_cast()