From 0a73ada7b57c4e69a231793776bee30706ae862b Mon Sep 17 00:00:00 2001 From: leipeng Date: Wed, 20 Oct 2021 14:04:58 -0700 Subject: [PATCH] remove unused local obj and simpilify comple code (#9052) Summary: This PR does not change code sematics, it just changes for: 1. local obj `nonmem_w` and `lfile` are unused 2. null check for `delete ptr` is unnecessary 3. use `unique_ptr::reset` instead of `release` + `delete` Pull Request resolved: https://github.com/facebook/rocksdb/pull/9052 Reviewed By: zhichao-cao Differential Revision: D31801661 Pulled By: anand1976 fbshipit-source-id: 16a77d45da8c8833bf5bf3bce546bb3711b335df --- db/db_impl/db_impl_write.cc | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/db/db_impl/db_impl_write.cc b/db/db_impl/db_impl_write.cc index fe98967584..73e2eeb7f9 100644 --- a/db/db_impl/db_impl_write.cc +++ b/db/db_impl/db_impl_write.cc @@ -1756,8 +1756,6 @@ void DBImpl::NotifyOnMemTableSealed(ColumnFamilyData* /*cfd*/, // two_write_queues_ is true (This is to simplify the reasoning.) Status DBImpl::SwitchMemtable(ColumnFamilyData* cfd, WriteContext* context) { mutex_.AssertHeld(); - WriteThread::Writer nonmem_w; - std::unique_ptr lfile; log::Writer* new_log = nullptr; MemTable* new_mem = nullptr; IOStatus io_s; @@ -1861,17 +1859,9 @@ Status DBImpl::SwitchMemtable(ColumnFamilyData* cfd, WriteContext* context) { if (!s.ok()) { // how do we fail if we're not creating new log? assert(creating_new_log); - if (new_mem) { - delete new_mem; - } - if (new_log) { - delete new_log; - } - SuperVersion* new_superversion = - context->superversion_context.new_superversion.release(); - if (new_superversion != nullptr) { - delete new_superversion; - } + delete new_mem; + delete new_log; + context->superversion_context.new_superversion.reset(); // We may have lost data from the WritableFileBuffer in-memory buffer for // the current log, so treat it as a fatal error and set bg_error if (!io_s.ok()) {