Skip to content

Commit 324c46c

Browse files
rockeetinikep
authored andcommitted
m_auto_incr_map: reduce a redundant search operation (percona#1259)
Upstream commit ID: facebook/mysql-5.6@0eccd65 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: facebook/mysql-5.6#1259 Reviewed By: lth Differential Revision: D42928166 Pulled By: hermanlee fbshipit-source-id: 57a0d0af0e1e33cea97ad5e37179885e3b72f6e9
1 parent 316fa20 commit 324c46c

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

storage/rocksdb/ha_rocksdb.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3872,14 +3872,15 @@ class Rdb_transaction {
38723872
}
38733873

38743874
void set_auto_incr(const GL_INDEX_ID &gl_index_id, ulonglong curr_id) {
3875-
m_auto_incr_map[gl_index_id] =
3876-
std::max(m_auto_incr_map[gl_index_id], curr_id);
3875+
auto &existing = m_auto_incr_map[gl_index_id];
3876+
existing = std::max(existing, curr_id);
38773877
}
38783878

38793879
#ifndef NDEBUG
38803880
ulonglong get_auto_incr(const GL_INDEX_ID &gl_index_id) {
3881-
if (m_auto_incr_map.count(gl_index_id) > 0) {
3882-
return m_auto_incr_map[gl_index_id];
3881+
auto iter = m_auto_incr_map.find(gl_index_id);
3882+
if (m_auto_incr_map.end() != iter) {
3883+
return iter->second;
38833884
}
38843885
return 0;
38853886
}

0 commit comments

Comments
 (0)