From dcd842754451c39e4d36589827b2407c16664f1f Mon Sep 17 00:00:00 2001 From: leipeng Date: Thu, 12 Jan 2023 09:54:42 +0800 Subject: [PATCH] m_auto_incr_map: reduce a redundant search operation --- 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 83eac3c9fc0c..529f8c77437c 100644 --- a/storage/rocksdb/ha_rocksdb.cc +++ b/storage/rocksdb/ha_rocksdb.cc @@ -4200,14 +4200,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; }