Skip to content

Commit 57a0d0a

Browse files
hermanleeHerman Lee
authored andcommitted
[mysql-5.6][PR] m_auto_incr_map: reduce a redundant search operation
Summary: This PR reduced redundant searchs on `m_auto_incr_map`. Pull Request resolved: facebook#1259 GitHub Author: leipeng <peng@topling.cn> Test Plan: Imported from GitHub, without a `Test Plan:` line. Reviewers: luqun, rpan, mung, chni Reviewed By: mung Subscribers: webscalesql-eng@fb.com Differential Revision: https://phabricator.intern.facebook.com/D42928166 Tags: accept2ship
1 parent f8845e8 commit 57a0d0a

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)