Skip to content

Commit 717f21f

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 4654810 commit 717f21f

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

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

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

0 commit comments

Comments
 (0)