mirror of https://github.com/facebook/rocksdb.git
avoid find() -> insert() sequence (#11743)
Summary: when a key is recorded for locking in a pessimistic transaction, the key is first looked up in a map, and then inserted into the map if it was not already contained. this can be simplified to an unconditional insert. in the ideal case that all keys are unique, this saves all the find() operations. Pull Request resolved: https://github.com/facebook/rocksdb/pull/11743 Reviewed By: anand1976 Differential Revision: D48656798 Pulled By: ajkr fbshipit-source-id: d0150de2db757e0c05e1797cfc24380790c71276
This commit is contained in:
parent
ecbeb305a0
commit
0b8b17a9d1
|
@ -888,14 +888,8 @@ Status PessimisticTransaction::LockBatch(WriteBatch* batch,
|
|||
Handler() {}
|
||||
|
||||
void RecordKey(uint32_t column_family_id, const Slice& key) {
|
||||
std::string key_str = key.ToString();
|
||||
|
||||
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.
|
||||
cfh_keys.insert({std::move(key_str)});
|
||||
}
|
||||
cfh_keys.insert(key.ToString());
|
||||
}
|
||||
|
||||
Status PutCF(uint32_t column_family_id, const Slice& key,
|
||||
|
|
Loading…
Reference in New Issue