From 2b5df21e95096fbfc25e8aac33b2153302e710e9 Mon Sep 17 00:00:00 2001 From: Yanqin Jin Date: Mon, 2 May 2022 19:39:24 -0700 Subject: [PATCH] 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 --- .../transactions/lock/point/point_lock_tracker.cc | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/utilities/transactions/lock/point/point_lock_tracker.cc b/utilities/transactions/lock/point/point_lock_tracker.cc index 837f377de..6204a8f02 100644 --- a/utilities/transactions/lock/point/point_lock_tracker.cc +++ b/utilities/transactions/lock/point/point_lock_tracker.cc @@ -44,25 +44,12 @@ class TrackedKeysIterator : public LockTracker::KeyIterator { void PointLockTracker::Track(const PointLockRequest& r) { 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 it = result.first; if (!result.second && r.seq < it->second.seq) { // Now tracking this key with an earlier sequence number 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 // 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