From 65621f712f2cdfffe52806c1281f82e90334ae83 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) 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 16eb28456f64..e13a01536557 100644 --- a/storage/rocksdb/ha_rocksdb.cc +++ b/storage/rocksdb/ha_rocksdb.cc @@ -3160,14 +3160,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; }