Skip to content

Commit 0eccd65

Browse files
rockeetfacebook-github-bot
authored andcommitted
m_auto_incr_map: reduce a redundant search operation (#1259)
Summary: This PR reduced redundant searchs on `m_auto_incr_map`. Pull Request resolved: #1259 Reviewed By: lth Differential Revision: D42928166 Pulled By: hermanlee fbshipit-source-id: 57a0d0a
1 parent 5d46fb1 commit 0eccd65

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
@@ -4249,14 +4249,15 @@ class Rdb_transaction {
42494249
}
42504250

42514251
void set_auto_incr(const GL_INDEX_ID &gl_index_id, ulonglong curr_id) {
4252-
m_auto_incr_map[gl_index_id] =
4253-
std::max(m_auto_incr_map[gl_index_id], curr_id);
4252+
auto &existing = m_auto_incr_map[gl_index_id];
4253+
existing = std::max(existing, curr_id);
42544254
}
42554255

42564256
#ifndef NDEBUG
42574257
ulonglong get_auto_incr(const GL_INDEX_ID &gl_index_id) {
4258-
if (m_auto_incr_map.count(gl_index_id) > 0) {
4259-
return m_auto_incr_map[gl_index_id];
4258+
auto iter = m_auto_incr_map.find(gl_index_id);
4259+
if (m_auto_incr_map.end() != iter) {
4260+
return iter->second;
42604261
}
42614262
return 0;
42624263
}

0 commit comments

Comments
 (0)