Remove ifdef for try_emplace after upgrading to c++17 (#9932)
Summary: Test plan make check Pull Request resolved: https://github.com/facebook/rocksdb/pull/9932 Reviewed By: ajkr Differential Revision: D36085404 Pulled By: riversand963 fbshipit-source-id: 2ece14ca0e2e4c1288339ff79e7e126b76eaf786
This commit is contained in:
parent
cda34dd64a
commit
2b5df21e95
@ -44,25 +44,12 @@ class TrackedKeysIterator : public LockTracker::KeyIterator {
|
|||||||
|
|
||||||
void PointLockTracker::Track(const PointLockRequest& r) {
|
void PointLockTracker::Track(const PointLockRequest& r) {
|
||||||
auto& keys = tracked_keys_[r.column_family_id];
|
auto& keys = tracked_keys_[r.column_family_id];
|
||||||
#ifdef __cpp_lib_unordered_map_try_emplace
|
|
||||||
// use c++17's try_emplace if available, to avoid rehashing the key
|
|
||||||
// in case it is not already in the map
|
|
||||||
auto result = keys.try_emplace(r.key, r.seq);
|
auto result = keys.try_emplace(r.key, r.seq);
|
||||||
auto it = result.first;
|
auto it = result.first;
|
||||||
if (!result.second && r.seq < it->second.seq) {
|
if (!result.second && r.seq < it->second.seq) {
|
||||||
// Now tracking this key with an earlier sequence number
|
// Now tracking this key with an earlier sequence number
|
||||||
it->second.seq = r.seq;
|
it->second.seq = r.seq;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
auto it = keys.find(r.key);
|
|
||||||
if (it == keys.end()) {
|
|
||||||
auto result = keys.emplace(r.key, TrackedKeyInfo(r.seq));
|
|
||||||
it = result.first;
|
|
||||||
} else if (r.seq < it->second.seq) {
|
|
||||||
// Now tracking this key with an earlier sequence number
|
|
||||||
it->second.seq = r.seq;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
// else we do not update the seq. The smaller the tracked seq, the stronger it
|
// else we do not update the seq. The smaller the tracked seq, the stronger it
|
||||||
// the guarantee since it implies from the seq onward there has not been a
|
// the guarantee since it implies from the seq onward there has not been a
|
||||||
// concurrent update to the key. So we update the seq if it implies stronger
|
// concurrent update to the key. So we update the seq if it implies stronger
|
||||||
|
Loading…
Reference in New Issue
Block a user