Skip to content

Commit 2bf64c5

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 e445e72 commit 2bf64c5

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
@@ -3859,14 +3859,15 @@ class Rdb_transaction {
38593859
}
38603860

38613861
void set_auto_incr(const GL_INDEX_ID &gl_index_id, ulonglong curr_id) {
3862-
m_auto_incr_map[gl_index_id] =
3863-
std::max(m_auto_incr_map[gl_index_id], curr_id);
3862+
auto &existing = m_auto_incr_map[gl_index_id];
3863+
existing = std::max(existing, curr_id);
38643864
}
38653865

38663866
#ifndef NDEBUG
38673867
ulonglong get_auto_incr(const GL_INDEX_ID &gl_index_id) {
3868-
if (m_auto_incr_map.count(gl_index_id) > 0) {
3869-
return m_auto_incr_map[gl_index_id];
3868+
auto iter = m_auto_incr_map.find(gl_index_id);
3869+
if (m_auto_incr_map.end() != iter) {
3870+
return iter->second;
38703871
}
38713872
return 0;
38723873
}

0 commit comments

Comments
 (0)