From adeaca4efe007686f669569447ae958a087313ff Mon Sep 17 00:00:00 2001 From: Green Sky Date: Fri, 6 Dec 2024 16:36:02 +0100 Subject: [PATCH] early out have when we have all --- solanaceae/ngc_ft1_sha1/sha1_ngcft1.cpp | 8 ++++++-- solanaceae/ngc_hs2/ngc_hs2_send.cpp | 1 - 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/solanaceae/ngc_ft1_sha1/sha1_ngcft1.cpp b/solanaceae/ngc_ft1_sha1/sha1_ngcft1.cpp index 3e3a513..94d4aa4 100644 --- a/solanaceae/ngc_ft1_sha1/sha1_ngcft1.cpp +++ b/solanaceae/ngc_ft1_sha1/sha1_ngcft1.cpp @@ -1399,8 +1399,6 @@ bool SHA1_NGCFT1::onEvent(const Events::NGCEXT_ft1_have& e) { return false; } - const size_t num_total_chunks = o.get().chunks.size(); - const auto c = _tcm.getContactGroupPeer(e.group_number, e.peer_number); assert(static_cast(c)); _tox_peer_to_contact[combine_ids(e.group_number, e.peer_number)] = c; // cache @@ -1411,6 +1409,8 @@ bool SHA1_NGCFT1::onEvent(const Events::NGCEXT_ft1_have& e) { //c.emplace_or_replace(); } + const size_t num_total_chunks = o.get().chunks.size(); + auto& remote_have = o.get_or_emplace().others; if (!remote_have.contains(c)) { // init @@ -1420,6 +1420,10 @@ bool SHA1_NGCFT1::onEvent(const Events::NGCEXT_ft1_have& e) { //c.emplace_or_replace(); } + if (o.all_of()) { + return true; // we dont care beyond this point + } + auto& remote_have_peer = remote_have.at(c); if (remote_have_peer.have_all) { return true; // peer somehow already had all, ignoring diff --git a/solanaceae/ngc_hs2/ngc_hs2_send.cpp b/solanaceae/ngc_hs2/ngc_hs2_send.cpp index 5e7d354..ed255f8 100644 --- a/solanaceae/ngc_hs2/ngc_hs2_send.cpp +++ b/solanaceae/ngc_hs2/ngc_hs2_send.cpp @@ -251,7 +251,6 @@ std::vector NGCHS2Send::buildHSFileRange(Contact3Handle c, uint64_t ts_ continue; // skip } - const auto& [c_from_c, c_to_c] = msg_reg.get(e); if (c_to_c.c != c) {