codebase wide: use try_emplace when appropriate
C++17 introduced try_emplace for maps to replace a pattern:
if(element not in a map) {
map.emplace(...)
}
try_emplace is more efficient and results in a more concise code.
This commit introduces usage of try_emplace when it's appropriate.
Tests: unit(dev)
Signed-off-by: Piotr Jastrzebski <piotr@scylladb.com>
Message-Id: <4970091ed770e233884633bf6d46111369e7d2dd.1597327358.git.piotr@scylladb.com>
This commit is contained in:
committed by
Avi Kivity
parent
39400f58fb
commit
01ea159fde
@@ -296,10 +296,7 @@ future<> db::commitlog_replayer::impl::process(stats* s, commitlog::buffer_and_r
|
||||
// lower than anything the new session will produce.
|
||||
if (cf.schema()->version() != fm.schema_version()) {
|
||||
auto& local_cm = _column_mappings.local().map;
|
||||
auto cm_it = local_cm.find(fm.schema_version());
|
||||
if (cm_it == local_cm.end()) {
|
||||
cm_it = local_cm.emplace(fm.schema_version(), src_cm).first;
|
||||
}
|
||||
auto cm_it = local_cm.try_emplace(fm.schema_version(), src_cm).first;
|
||||
const column_mapping& cm = cm_it->second;
|
||||
mutation m(cf.schema(), fm.decorated_key(*cf.schema()));
|
||||
converting_mutation_partition_applier v(cm, *cf.schema(), m.partition());
|
||||
|
||||
Reference in New Issue
Block a user