From 182cc0c17e34f3abd6251c20ece88f42313284cf Mon Sep 17 00:00:00 2001 From: leipeng Date: Wed, 1 Feb 2023 09:15:24 -0800 Subject: [PATCH] m_auto_incr_map: reduce a redundant search operation (#1259) Upstream commit ID: https://github.com/facebook/mysql-5.6/commit/0eccd65cb75cb4f25a53a43edfb61b6f88202be6 PS-8755: Merge percona-202301 (https://jira.percona.com/browse/PS-8755) Summary: This PR reduced redundant searchs on `m_auto_incr_map`. Pull Request resolved: https://github.com/facebook/mysql-5.6/pull/1259 Reviewed By: lth Differential Revision: D42928166 Pulled By: hermanlee fbshipit-source-id: 57a0d0af0e1e33cea97ad5e37179885e3b72f6e9 --- storage/rocksdb/ha_rocksdb.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/storage/rocksdb/ha_rocksdb.cc b/storage/rocksdb/ha_rocksdb.cc index 2a9224d807d7..cc7f18c0d635 100644 --- a/storage/rocksdb/ha_rocksdb.cc +++ b/storage/rocksdb/ha_rocksdb.cc @@ -3872,14 +3872,15 @@ class Rdb_transaction { } void set_auto_incr(const GL_INDEX_ID &gl_index_id, ulonglong curr_id) { - m_auto_incr_map[gl_index_id] = - std::max(m_auto_incr_map[gl_index_id], curr_id); + auto &existing = m_auto_incr_map[gl_index_id]; + existing = std::max(existing, curr_id); } #ifndef NDEBUG ulonglong get_auto_incr(const GL_INDEX_ID &gl_index_id) { - if (m_auto_incr_map.count(gl_index_id) > 0) { - return m_auto_incr_map[gl_index_id]; + auto iter = m_auto_incr_map.find(gl_index_id); + if (m_auto_incr_map.end() != iter) { + return iter->second; } return 0; }