diff --git a/db/memtable_list.cc b/db/memtable_list.cc index 1a23d18cd..acdba0896 100644 --- a/db/memtable_list.cc +++ b/db/memtable_list.cc @@ -43,22 +43,20 @@ void MemTableListVersion::UnrefMemTable(autovector* to_delete, } MemTableListVersion::MemTableListVersion( - size_t* parent_memtable_list_memory_usage, MemTableListVersion* old) + size_t* parent_memtable_list_memory_usage, const MemTableListVersion& old) : max_write_buffer_number_to_maintain_( - old->max_write_buffer_number_to_maintain_), + old.max_write_buffer_number_to_maintain_), max_write_buffer_size_to_maintain_( - old->max_write_buffer_size_to_maintain_), + old.max_write_buffer_size_to_maintain_), parent_memtable_list_memory_usage_(parent_memtable_list_memory_usage) { - if (old != nullptr) { - memlist_ = old->memlist_; - for (auto& m : memlist_) { - m->Ref(); - } + memlist_ = old.memlist_; + for (auto& m : memlist_) { + m->Ref(); + } - memlist_history_ = old->memlist_history_; - for (auto& m : memlist_history_) { - m->Ref(); - } + memlist_history_ = old.memlist_history_; + for (auto& m : memlist_history_) { + m->Ref(); } } @@ -604,7 +602,7 @@ void MemTableList::InstallNewVersion() { } else { // somebody else holds the current version, we need to create new one MemTableListVersion* version = current_; - current_ = new MemTableListVersion(¤t_memory_usage_, current_); + current_ = new MemTableListVersion(¤t_memory_usage_, *version); current_->Ref(); version->Unref(); } diff --git a/db/memtable_list.h b/db/memtable_list.h index bf6750bf2..9991df566 100644 --- a/db/memtable_list.h +++ b/db/memtable_list.h @@ -44,7 +44,7 @@ struct FlushJobInfo; class MemTableListVersion { public: explicit MemTableListVersion(size_t* parent_memtable_list_memory_usage, - MemTableListVersion* old = nullptr); + const MemTableListVersion& old); explicit MemTableListVersion(size_t* parent_memtable_list_memory_usage, int max_write_buffer_number_to_maintain, int64_t max_write_buffer_size_to_maintain); diff --git a/utilities/transactions/transaction_base.cc b/utilities/transactions/transaction_base.cc index 32fb714aa..92b3956e1 100644 --- a/utilities/transactions/transaction_base.cc +++ b/utilities/transactions/transaction_base.cc @@ -312,8 +312,7 @@ std::vector TransactionBaseImpl::MultiGet( std::vector stat_list(num_keys); for (size_t i = 0; i < num_keys; ++i) { - std::string* value = values ? &(*values)[i] : nullptr; - stat_list[i] = Get(read_options, column_family[i], keys[i], value); + stat_list[i] = Get(read_options, column_family[i], keys[i], &(*values)[i]); } return stat_list; @@ -350,8 +349,7 @@ std::vector TransactionBaseImpl::MultiGetForUpdate( // TODO(agiardullo): optimize multiget? std::vector stat_list(num_keys); for (size_t i = 0; i < num_keys; ++i) { - std::string* value = values ? &(*values)[i] : nullptr; - stat_list[i] = Get(read_options, column_family[i], keys[i], value); + stat_list[i] = Get(read_options, column_family[i], keys[i], &(*values)[i]); } return stat_list; diff --git a/utilities/transactions/write_prepared_txn_db.cc b/utilities/transactions/write_prepared_txn_db.cc index 76341d58b..45a192004 100644 --- a/utilities/transactions/write_prepared_txn_db.cc +++ b/utilities/transactions/write_prepared_txn_db.cc @@ -294,8 +294,7 @@ std::vector WritePreparedTxnDB::MultiGet( std::vector stat_list(num_keys); for (size_t i = 0; i < num_keys; ++i) { - std::string* value = values ? &(*values)[i] : nullptr; - stat_list[i] = this->Get(options, column_family[i], keys[i], value); + stat_list[i] = this->Get(options, column_family[i], keys[i], &(*values)[i]); } return stat_list; }