File tree Expand file tree Collapse file tree 1 file changed +6
-12
lines changed Expand file tree Collapse file tree 1 file changed +6
-12
lines changed Original file line number Diff line number Diff line change @@ -208,19 +208,13 @@ CBlockIndex* BlockManager::InsertBlockIndex(const uint256& hash)
208
208
return nullptr ;
209
209
}
210
210
211
- // Return existing
212
- BlockMap::iterator mi = m_block_index.find (hash);
213
- if (mi != m_block_index.end ()) {
214
- return &(*mi).second ;
211
+ // Return existing or create new
212
+ auto [mi, inserted] = m_block_index.try_emplace (hash);
213
+ CBlockIndex* pindex = &(*mi).second ;
214
+ if (inserted) {
215
+ pindex->phashBlock = &((*mi).first );
215
216
}
216
-
217
- // Create new
218
- CBlockIndex new_index{};
219
- mi = m_block_index.insert (std::make_pair (hash, std::move (new_index))).first ;
220
- CBlockIndex* pindexNew = &(*mi).second ;
221
- pindexNew->phashBlock = &((*mi).first );
222
-
223
- return pindexNew;
217
+ return pindex;
224
218
}
225
219
226
220
bool BlockManager::LoadBlockIndex (
You can’t perform that action at this time.
0 commit comments