From 88dc6990991fe9c0284921456d448a32c45ff595 Mon Sep 17 00:00:00 2001 From: Victor Zarubkin Date: Thu, 8 Dec 2016 22:19:45 +0300 Subject: [PATCH] No need to check for nullptr while deleting --- easy_profiler_core/profile_manager.cpp | 5 +---- profiler_gui/easy_graphics_scrollbar.cpp | 24 +++++++----------------- 2 files changed, 8 insertions(+), 21 deletions(-) diff --git a/easy_profiler_core/profile_manager.cpp b/easy_profiler_core/profile_manager.cpp index fbdd8ef..b6109b8 100644 --- a/easy_profiler_core/profile_manager.cpp +++ b/easy_profiler_core/profile_manager.cpp @@ -412,10 +412,7 @@ ProfileManager::~ProfileManager() #endif for (auto desc : m_descriptors) - { - if (desc != nullptr) - delete desc; - } + delete desc; } #ifndef EASY_MAGIC_STATIC_CPP11 diff --git a/profiler_gui/easy_graphics_scrollbar.cpp b/profiler_gui/easy_graphics_scrollbar.cpp index 9b2feaa..a2ec8e7 100644 --- a/profiler_gui/easy_graphics_scrollbar.cpp +++ b/profiler_gui/easy_graphics_scrollbar.cpp @@ -249,8 +249,7 @@ EasyHystogramItem::~EasyHystogramItem() m_bReady.store(true, ::std::memory_order_release); if (m_workerThread.joinable()) m_workerThread.join(); - if (m_temporaryImage != nullptr) - delete m_temporaryImage; + delete m_temporaryImage; } QRectF EasyHystogramItem::boundingRect() const @@ -716,11 +715,8 @@ void EasyHystogramItem::setSource(::profiler::thread_id_t _thread_id, const ::pr if (m_workerThread.joinable()) m_workerThread.join(); - if (m_temporaryImage != nullptr) - { - delete m_temporaryImage; - m_temporaryImage = nullptr; - } + delete m_temporaryImage; + m_temporaryImage = nullptr; m_selectedBlocks.clear(); ::profiler::BlocksTree::children_t().swap(m_selectedBlocks); @@ -799,11 +795,8 @@ void EasyHystogramItem::setSource(::profiler::thread_id_t _thread_id, ::profiler if (m_workerThread.joinable()) m_workerThread.join(); - if (m_temporaryImage != nullptr) - { - delete m_temporaryImage; - m_temporaryImage = nullptr; - } + delete m_temporaryImage; + m_temporaryImage = nullptr; m_selectedBlocks.clear(); ::profiler::BlocksTree::children_t().swap(m_selectedBlocks); @@ -964,11 +957,8 @@ void EasyHystogramItem::updateImage() m_workerThread.join(); m_bReady.store(false, ::std::memory_order_release); - if (m_temporaryImage != nullptr) - { - delete m_temporaryImage; - m_temporaryImage = nullptr; - } + delete m_temporaryImage; + m_temporaryImage = nullptr; m_workerThread = ::std::move(::std::thread([this](HystRegime _regime, qreal _current_scale, qreal _minimum, qreal _maximum, qreal _range, qreal _value, qreal _width, bool _bindMode,