From e61a8c5c1b55f6267553f8e0db0f61b52c2f683d Mon Sep 17 00:00:00 2001 From: Chris Thrasher Date: Fri, 10 Jun 2022 00:06:57 -0600 Subject: [PATCH] Remove empty non-virtual destructors While this practice didn't matter too much in C++03, it becomes a pessimization with the introduction of C++11 move semantics. When a destructor is defined, no matter how trivial it is, it implicitly disables move semantics. Because the compiler can sometimes move objects without the programmer asking, the inability to make these moves can unnecessarily slow down SFML programs. Removing these trivial destructors is an easy way to enable move semantics for more SFML types and quietly speed up everyone's code. --- src/SFML/Graphics/Font.cpp | 5 +---- src/SFML/Graphics/ImageLoader.cpp | 7 ------- src/SFML/Graphics/ImageLoader.hpp | 6 ------ src/SFML/Window/Android/CursorImpl.cpp | 7 ------- src/SFML/Window/Android/CursorImpl.hpp | 8 -------- src/SFML/Window/DRM/CursorImpl.cpp | 6 ------ src/SFML/Window/DRM/CursorImpl.hpp | 8 -------- src/SFML/Window/iOS/CursorImpl.cpp | 7 ------- src/SFML/Window/iOS/CursorImpl.hpp | 8 -------- 9 files changed, 1 insertion(+), 61 deletions(-) diff --git a/src/SFML/Graphics/Font.cpp b/src/SFML/Graphics/Font.cpp index 5defd921..ffb640c8 100644 --- a/src/SFML/Graphics/Font.cpp +++ b/src/SFML/Graphics/Font.cpp @@ -130,10 +130,7 @@ m_pixelBuffer(copy.m_pixelBuffer) //////////////////////////////////////////////////////////// -Font::~Font() -{ - cleanup(); -} +Font::~Font() = default; //////////////////////////////////////////////////////////// diff --git a/src/SFML/Graphics/ImageLoader.cpp b/src/SFML/Graphics/ImageLoader.cpp index 428ebe9c..b6630c93 100644 --- a/src/SFML/Graphics/ImageLoader.cpp +++ b/src/SFML/Graphics/ImageLoader.cpp @@ -90,13 +90,6 @@ ImageLoader::ImageLoader() } -//////////////////////////////////////////////////////////// -ImageLoader::~ImageLoader() -{ - // Nothing to do -} - - //////////////////////////////////////////////////////////// bool ImageLoader::loadImageFromFile(const std::filesystem::path& filename, std::vector& pixels, Vector2u& size) { diff --git a/src/SFML/Graphics/ImageLoader.hpp b/src/SFML/Graphics/ImageLoader.hpp index 2d66d821..1e8b2617 100644 --- a/src/SFML/Graphics/ImageLoader.hpp +++ b/src/SFML/Graphics/ImageLoader.hpp @@ -127,12 +127,6 @@ private: //////////////////////////////////////////////////////////// ImageLoader(); - //////////////////////////////////////////////////////////// - /// \brief Destructor - /// - //////////////////////////////////////////////////////////// - ~ImageLoader(); - //////////////////////////////////////////////////////////// /// \brief Deleted copy constructor /// diff --git a/src/SFML/Window/Android/CursorImpl.cpp b/src/SFML/Window/Android/CursorImpl.cpp index 5999fb56..f09b269d 100644 --- a/src/SFML/Window/Android/CursorImpl.cpp +++ b/src/SFML/Window/Android/CursorImpl.cpp @@ -39,13 +39,6 @@ CursorImpl::CursorImpl() } -//////////////////////////////////////////////////////////// -CursorImpl::~CursorImpl() -{ - // Nothing. -} - - //////////////////////////////////////////////////////////// bool CursorImpl::loadFromPixels(const Uint8* /* pixels */, Vector2u /* size */, Vector2u /* hotspot */) { diff --git a/src/SFML/Window/Android/CursorImpl.hpp b/src/SFML/Window/Android/CursorImpl.hpp index 822442f0..bb4b1470 100644 --- a/src/SFML/Window/Android/CursorImpl.hpp +++ b/src/SFML/Window/Android/CursorImpl.hpp @@ -55,14 +55,6 @@ public: //////////////////////////////////////////////////////////// CursorImpl(); - //////////////////////////////////////////////////////////// - /// \brief Destructor - /// - /// Refer to sf::Cursor::~Cursor(). - /// - //////////////////////////////////////////////////////////// - ~CursorImpl(); - //////////////////////////////////////////////////////////// /// \brief Deleted copy constructor /// diff --git a/src/SFML/Window/DRM/CursorImpl.cpp b/src/SFML/Window/DRM/CursorImpl.cpp index dbe73dcb..e1e60231 100644 --- a/src/SFML/Window/DRM/CursorImpl.cpp +++ b/src/SFML/Window/DRM/CursorImpl.cpp @@ -39,12 +39,6 @@ CursorImpl::CursorImpl() } -//////////////////////////////////////////////////////////// -CursorImpl::~CursorImpl() -{ -} - - //////////////////////////////////////////////////////////// bool CursorImpl::loadFromPixels(const Uint8* /*pixels*/, Vector2u /*size*/, Vector2u /*hotspot*/) { diff --git a/src/SFML/Window/DRM/CursorImpl.hpp b/src/SFML/Window/DRM/CursorImpl.hpp index c78d918c..5d24c324 100644 --- a/src/SFML/Window/DRM/CursorImpl.hpp +++ b/src/SFML/Window/DRM/CursorImpl.hpp @@ -53,14 +53,6 @@ public: //////////////////////////////////////////////////////////// CursorImpl(); - //////////////////////////////////////////////////////////// - /// \brief Destructor - /// - /// Refer to sf::Cursor::~Cursor(). - /// - //////////////////////////////////////////////////////////// - ~CursorImpl(); - //////////////////////////////////////////////////////////// /// \brief Deleted copy constructor /// diff --git a/src/SFML/Window/iOS/CursorImpl.cpp b/src/SFML/Window/iOS/CursorImpl.cpp index f5648adb..a93bfed8 100644 --- a/src/SFML/Window/iOS/CursorImpl.cpp +++ b/src/SFML/Window/iOS/CursorImpl.cpp @@ -39,13 +39,6 @@ CursorImpl::CursorImpl() } -//////////////////////////////////////////////////////////// -CursorImpl::~CursorImpl() -{ - // Nothing. -} - - //////////////////////////////////////////////////////////// bool CursorImpl::loadFromPixels(const Uint8* /* pixels */, Vector2u /* size */, Vector2u /* hotspot */) { diff --git a/src/SFML/Window/iOS/CursorImpl.hpp b/src/SFML/Window/iOS/CursorImpl.hpp index 5c7588ec..db4849af 100644 --- a/src/SFML/Window/iOS/CursorImpl.hpp +++ b/src/SFML/Window/iOS/CursorImpl.hpp @@ -55,14 +55,6 @@ public: //////////////////////////////////////////////////////////// CursorImpl(); - //////////////////////////////////////////////////////////// - /// \brief Destructor - /// - /// Refer to sf::Cursor::~Cursor(). - /// - //////////////////////////////////////////////////////////// - ~CursorImpl(); - //////////////////////////////////////////////////////////// /// \brief Deleted copy constructor ///