From 94439a334e77aab54a2945c000e066090a3f233e Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Thu, 26 Apr 2018 16:39:59 -0700 Subject: [PATCH] ircd::db: Cleanup/Simplify db open ptr construction. --- ircd/db.cc | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/ircd/db.cc b/ircd/db.cc index 33b7c70f6..c471c30c8 100644 --- a/ircd/db.cc +++ b/ircd/db.cc @@ -559,31 +559,28 @@ try rocksdb::DB::Open(opts, path, columns, &handles, &ptr) }; - try // Assign the column index numbers given by db + std::unique_ptr ret { - for(const auto &handle : handles) - { - this->columns.at(handle->GetID())->handle.reset(handle); - this->column_index.at(handle->GetName()) = handle->GetID(); - } + ptr + }; - for(size_t i(0); i < this->columns.size(); ++i) - if(db::id(*this->columns[i]) != i) - throw error - { - "Columns misaligned: expecting id[%zd] got id[%u] '%s'", - i, - db::id(*this->columns[i]), - db::name(*this->columns[i]) - }; - } - catch(const std::exception &e) + for(const auto &handle : handles) { - delete ptr; - throw; + this->columns.at(handle->GetID())->handle.reset(handle); + this->column_index.at(handle->GetName()) = handle->GetID(); } - return std::unique_ptr(ptr); + for(size_t i(0); i < this->columns.size(); ++i) + if(db::id(*this->columns[i]) != i) + throw error + { + "Columns misaligned: expecting id[%zd] got id[%u] '%s'", + i, + db::id(*this->columns[i]), + db::name(*this->columns[i]) + }; + + return ret; }()} ,checkpoint{[this] {