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.
This commit is contained in:
Chris Thrasher 2022-06-10 00:06:57 -06:00 committed by Vittorio Romeo
parent 709530d062
commit e61a8c5c1b
9 changed files with 1 additions and 61 deletions

View File

@ -130,10 +130,7 @@ m_pixelBuffer(copy.m_pixelBuffer)
////////////////////////////////////////////////////////////
Font::~Font()
{
cleanup();
}
Font::~Font() = default;
////////////////////////////////////////////////////////////

View File

@ -90,13 +90,6 @@ ImageLoader::ImageLoader()
}
////////////////////////////////////////////////////////////
ImageLoader::~ImageLoader()
{
// Nothing to do
}
////////////////////////////////////////////////////////////
bool ImageLoader::loadImageFromFile(const std::filesystem::path& filename, std::vector<Uint8>& pixels, Vector2u& size)
{

View File

@ -127,12 +127,6 @@ private:
////////////////////////////////////////////////////////////
ImageLoader();
////////////////////////////////////////////////////////////
/// \brief Destructor
///
////////////////////////////////////////////////////////////
~ImageLoader();
////////////////////////////////////////////////////////////
/// \brief Deleted copy constructor
///

View File

@ -39,13 +39,6 @@ CursorImpl::CursorImpl()
}
////////////////////////////////////////////////////////////
CursorImpl::~CursorImpl()
{
// Nothing.
}
////////////////////////////////////////////////////////////
bool CursorImpl::loadFromPixels(const Uint8* /* pixels */, Vector2u /* size */, Vector2u /* hotspot */)
{

View File

@ -55,14 +55,6 @@ public:
////////////////////////////////////////////////////////////
CursorImpl();
////////////////////////////////////////////////////////////
/// \brief Destructor
///
/// Refer to sf::Cursor::~Cursor().
///
////////////////////////////////////////////////////////////
~CursorImpl();
////////////////////////////////////////////////////////////
/// \brief Deleted copy constructor
///

View File

@ -39,12 +39,6 @@ CursorImpl::CursorImpl()
}
////////////////////////////////////////////////////////////
CursorImpl::~CursorImpl()
{
}
////////////////////////////////////////////////////////////
bool CursorImpl::loadFromPixels(const Uint8* /*pixels*/, Vector2u /*size*/, Vector2u /*hotspot*/)
{

View File

@ -53,14 +53,6 @@ public:
////////////////////////////////////////////////////////////
CursorImpl();
////////////////////////////////////////////////////////////
/// \brief Destructor
///
/// Refer to sf::Cursor::~Cursor().
///
////////////////////////////////////////////////////////////
~CursorImpl();
////////////////////////////////////////////////////////////
/// \brief Deleted copy constructor
///

View File

@ -39,13 +39,6 @@ CursorImpl::CursorImpl()
}
////////////////////////////////////////////////////////////
CursorImpl::~CursorImpl()
{
// Nothing.
}
////////////////////////////////////////////////////////////
bool CursorImpl::loadFromPixels(const Uint8* /* pixels */, Vector2u /* size */, Vector2u /* hotspot */)
{

View File

@ -55,14 +55,6 @@ public:
////////////////////////////////////////////////////////////
CursorImpl();
////////////////////////////////////////////////////////////
/// \brief Destructor
///
/// Refer to sf::Cursor::~Cursor().
///
////////////////////////////////////////////////////////////
~CursorImpl();
////////////////////////////////////////////////////////////
/// \brief Deleted copy constructor
///