Skip to content

Commit c7f7502

Browse files
authored
Merge pull request #745 from evoskuil/master
Remove unnecessary shared_ptr copy.
2 parents 15f37e4 + 8f51963 commit c7f7502

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

src/protocols/protocol_block_in_31800.cpp

+2-12
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,8 @@ bool protocol_block_in_31800::handle_receive_block(const code& ec,
281281
// Preconditions.
282282
// ........................................................................
283283

284-
// Intentional pointer copy.
285-
const auto block = message->block_ptr;
284+
// message lifetime is guaranteed, and therefore block_ptr is as well.
285+
const auto& block = message->block_ptr;
286286
const auto& hash = block->get_hash();
287287
const auto it = map_->find(hash);
288288
auto& query = archive();
@@ -353,11 +353,6 @@ bool protocol_block_in_31800::handle_receive_block(const code& ec,
353353
return false;
354354
}
355355

356-
// ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
357-
// This is an attempt to keep the shared pointer in scope.
358-
// Given that block is const this could also be reordered prior to check().
359-
// But this is not called in this scope, only by message deserialization.
360-
// ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
361356
if (!block->is_valid())
362357
{
363358
stop(fault(error::protocol2));
@@ -372,11 +367,6 @@ bool protocol_block_in_31800::handle_receive_block(const code& ec,
372367

373368
notify(ec, chase::checked, height);
374369
fire(events::block_archived, height);
375-
376-
// ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
377-
// block->serialized_size may keep block in scope during set_code above.
378-
// However the compiler may reorder this calculation since block is const.
379-
// ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
380370
count(block->serialized_size(true));
381371
map_->erase(it);
382372
if (is_idle())

0 commit comments

Comments
 (0)