Skip to content

Commit 65621f7

Browse files
rockeetinikep
authored andcommitted
m_auto_incr_map: reduce a redundant search operation (facebook#1259)
Summary: This PR reduced redundant searchs on `m_auto_incr_map`. Pull Request resolved: facebook#1259 Reviewed By: lth Differential Revision: D42928166 Pulled By: hermanlee fbshipit-source-id: 57a0d0a
1 parent 212d743 commit 65621f7

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
@@ -3160,14 +3160,15 @@ class Rdb_transaction {
31603160
}
31613161

31623162
void set_auto_incr(const GL_INDEX_ID &gl_index_id, ulonglong curr_id) {
3163-
m_auto_incr_map[gl_index_id] =
3164-
std::max(m_auto_incr_map[gl_index_id], curr_id);
3163+
auto &existing = m_auto_incr_map[gl_index_id];
3164+
existing = std::max(existing, curr_id);
31653165
}
31663166

31673167
#ifndef NDEBUG
31683168
ulonglong get_auto_incr(const GL_INDEX_ID &gl_index_id) {
3169-
if (m_auto_incr_map.count(gl_index_id) > 0) {
3170-
return m_auto_incr_map[gl_index_id];
3169+
auto iter = m_auto_incr_map.find(gl_index_id);
3170+
if (m_auto_incr_map.end() != iter) {
3171+
return iter->second;
31713172
}
31723173
return 0;
31733174
}

0 commit comments

Comments
 (0)