diff --git a/db/version_builder.cc b/db/version_builder.cc index 8a8aefcb8..53e25a446 100644 --- a/db/version_builder.cc +++ b/db/version_builder.cc @@ -303,10 +303,7 @@ class VersionBuilder::Rep { levels_[level].added_files.erase(exising); } } else { - auto exising = invalid_levels_[level].find(number); - if (exising != invalid_levels_[level].end()) { - invalid_levels_[level].erase(exising); - } else { + if (invalid_levels_[level].erase(number) == 0) { // Deleting an non-existing file on invalid level. has_invalid_levels_ = true; } @@ -326,8 +323,9 @@ class VersionBuilder::Rep { levels_[level].added_files[f->fd.GetNumber()] = f; } else { uint64_t number = new_file.second.fd.GetNumber(); - if (invalid_levels_[level].count(number) == 0) { - invalid_levels_[level].insert(number); + auto& lvls = invalid_levels_[level]; + if (lvls.count(number) == 0) { + lvls.insert(number); } else { // Creating an already existing file on invalid level. has_invalid_levels_ = true; diff --git a/utilities/transactions/pessimistic_transaction.cc b/utilities/transactions/pessimistic_transaction.cc index 1c0e2f063..c709d34b1 100644 --- a/utilities/transactions/pessimistic_transaction.cc +++ b/utilities/transactions/pessimistic_transaction.cc @@ -473,10 +473,11 @@ Status PessimisticTransaction::LockBatch(WriteBatch* batch, void RecordKey(uint32_t column_family_id, const Slice& key) { std::string key_str = key.ToString(); - auto iter = (keys_)[column_family_id].find(key_str); - if (iter == (keys_)[column_family_id].end()) { + auto& cfh_keys = keys_[column_family_id]; + auto iter = cfh_keys.find(key_str); + if (iter == cfh_keys.end()) { // key not yet seen, store it. - (keys_)[column_family_id].insert({std::move(key_str)}); + cfh_keys.insert({std::move(key_str)}); } } diff --git a/utilities/transactions/transaction_base.cc b/utilities/transactions/transaction_base.cc index 637a38b9a..c10c1795f 100644 --- a/utilities/transactions/transaction_base.cc +++ b/utilities/transactions/transaction_base.cc @@ -170,7 +170,7 @@ Status TransactionBaseImpl::RollbackToSavePoint() { } if (tracked_keys_iter->second.num_reads == 0 && tracked_keys_iter->second.num_writes == 0) { - tracked_keys_[column_family_id].erase(tracked_keys_iter); + cf_tracked_keys.erase(tracked_keys_iter); } } }