We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
try_emplace
1 parent 27a26ed commit 6442be2Copy full SHA for 6442be2
1 file changed
include/CXXGraph/Partitioning/CoordinatedPartitionState.hpp
@@ -110,10 +110,8 @@ template <typename T>
110
std::shared_ptr<Record<T>> CoordinatedPartitionState<T>::getRecord(
111
CXXGraph::id_t x) {
112
std::lock_guard<std::mutex> lock(*record_map_mutex);
113
- if (record_map.find(x) == record_map.end()) {
114
- record_map[x] = std::make_shared<CoordinatedRecord<T>>();
115
- }
116
- return record_map.at(x);
+ return record_map.try_emplace(x, std::make_shared<CoordinatedRecord<T>>())
+ .first->second;
117
}
118
119
template <typename T>
0 commit comments