save a few redundant container lookups (#5875)
Summary: This PR eliminates repeated lookups in associative or ordered containers when a single lookup suffices. Pull Request resolved: https://github.com/facebook/rocksdb/pull/5875 Differential Revision: D17753172 Pulled By: anand1976 fbshipit-source-id: 796b02b760082521d8c42a1cb65a76bf0e6c1b8e
This commit is contained in:
parent
19a97dd139
commit
da3b2840cb
@ -303,10 +303,7 @@ class VersionBuilder::Rep {
|
|||||||
levels_[level].added_files.erase(exising);
|
levels_[level].added_files.erase(exising);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
auto exising = invalid_levels_[level].find(number);
|
if (invalid_levels_[level].erase(number) == 0) {
|
||||||
if (exising != invalid_levels_[level].end()) {
|
|
||||||
invalid_levels_[level].erase(exising);
|
|
||||||
} else {
|
|
||||||
// Deleting an non-existing file on invalid level.
|
// Deleting an non-existing file on invalid level.
|
||||||
has_invalid_levels_ = true;
|
has_invalid_levels_ = true;
|
||||||
}
|
}
|
||||||
@ -326,8 +323,9 @@ class VersionBuilder::Rep {
|
|||||||
levels_[level].added_files[f->fd.GetNumber()] = f;
|
levels_[level].added_files[f->fd.GetNumber()] = f;
|
||||||
} else {
|
} else {
|
||||||
uint64_t number = new_file.second.fd.GetNumber();
|
uint64_t number = new_file.second.fd.GetNumber();
|
||||||
if (invalid_levels_[level].count(number) == 0) {
|
auto& lvls = invalid_levels_[level];
|
||||||
invalid_levels_[level].insert(number);
|
if (lvls.count(number) == 0) {
|
||||||
|
lvls.insert(number);
|
||||||
} else {
|
} else {
|
||||||
// Creating an already existing file on invalid level.
|
// Creating an already existing file on invalid level.
|
||||||
has_invalid_levels_ = true;
|
has_invalid_levels_ = true;
|
||||||
|
@ -473,10 +473,11 @@ Status PessimisticTransaction::LockBatch(WriteBatch* batch,
|
|||||||
void RecordKey(uint32_t column_family_id, const Slice& key) {
|
void RecordKey(uint32_t column_family_id, const Slice& key) {
|
||||||
std::string key_str = key.ToString();
|
std::string key_str = key.ToString();
|
||||||
|
|
||||||
auto iter = (keys_)[column_family_id].find(key_str);
|
auto& cfh_keys = keys_[column_family_id];
|
||||||
if (iter == (keys_)[column_family_id].end()) {
|
auto iter = cfh_keys.find(key_str);
|
||||||
|
if (iter == cfh_keys.end()) {
|
||||||
// key not yet seen, store it.
|
// key not yet seen, store it.
|
||||||
(keys_)[column_family_id].insert({std::move(key_str)});
|
cfh_keys.insert({std::move(key_str)});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,7 +170,7 @@ Status TransactionBaseImpl::RollbackToSavePoint() {
|
|||||||
}
|
}
|
||||||
if (tracked_keys_iter->second.num_reads == 0 &&
|
if (tracked_keys_iter->second.num_reads == 0 &&
|
||||||
tracked_keys_iter->second.num_writes == 0) {
|
tracked_keys_iter->second.num_writes == 0) {
|
||||||
tracked_keys_[column_family_id].erase(tracked_keys_iter);
|
cf_tracked_keys.erase(tracked_keys_iter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user