Skip to content

Commit

Permalink
m_auto_incr_map: reduce a redundant search operation (percona#1259)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rockeet authored and VarunNagaraju committed Jun 5, 2024
1 parent bdd83f9 commit 182cc0c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions storage/rocksdb/ha_rocksdb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3872,14 +3872,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;
}
Expand Down

0 comments on commit 182cc0c

Please sign in to comment.