From 52e95ca654fb16076115660a4e8babb939626359 Mon Sep 17 00:00:00 2001 From: Green Sky Date: Wed, 28 Feb 2024 01:07:17 +0100 Subject: [PATCH] forgot to check contact --- src/fragment_store/message_fragment_store.cpp | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/fragment_store/message_fragment_store.cpp b/src/fragment_store/message_fragment_store.cpp index 353787d..11124ed 100644 --- a/src/fragment_store/message_fragment_store.cpp +++ b/src/fragment_store/message_fragment_store.cpp @@ -701,12 +701,13 @@ FragmentID MessageFragmentStore::fragmentBefore(FragmentID fid) { } const auto& mtsrange = fh.get(); + const auto& m_c_id = fh.get().id; const auto& fuid = fh.get(); FragmentHandle current; - auto mts_view = fh.registry()->view(); - for (const auto& [it_f, it_mtsrange, it_fuid] : mts_view.each()) { + auto mts_view = fh.registry()->view(); + for (const auto& [it_f, it_mtsrange, it_m_c_id, it_fuid] : mts_view.each()) { // before means we compare end, so we dont jump over any if (it_mtsrange.end > mtsrange.end) { @@ -721,6 +722,11 @@ FragmentID MessageFragmentStore::fragmentBefore(FragmentID fid) { } } + // now we check contact (might be less cheap than range check) + if (it_m_c_id.id != m_c_id) { + continue; + } + // here we know that "it" is before // now we check for the largest, so the closest @@ -756,12 +762,13 @@ FragmentID MessageFragmentStore::fragmentAfter(FragmentID fid) { } const auto& mtsrange = fh.get(); + const auto& m_c_id = fh.get().id; const auto& fuid = fh.get(); FragmentHandle current; - auto mts_view = fh.registry()->view(); - for (const auto& [it_f, it_mtsrange, it_fuid] : mts_view.each()) { + auto mts_view = fh.registry()->view(); + for (const auto& [it_f, it_mtsrange, it_m_c_id, it_fuid] : mts_view.each()) { // after means we compare begin if (it_mtsrange.begin < mtsrange.begin) { @@ -777,6 +784,11 @@ FragmentID MessageFragmentStore::fragmentAfter(FragmentID fid) { } } + // now we check contact (might be less cheap than range check) + if (it_m_c_id.id != m_c_id) { + continue; + } + // here we know that "it" is after // now we check for the smallest, so the closest @@ -834,8 +846,6 @@ bool MessageFragmentStore::onEvent(const Fragment::Events::FragmentConstruct& e) // TODO: id lookup table, this is very inefficent for (const auto& [c_it, id_it] : _cr.view().each()) { if (frag_contact_id == id_it.data) { - //h.emplace_or_replace(c_it); - //return true; frag_contact = c_it; break; } @@ -850,6 +860,7 @@ bool MessageFragmentStore::onEvent(const Fragment::Events::FragmentConstruct& e) auto* msg_reg = _rmm.get(frag_contact); if (msg_reg == nullptr) { // msg reg not created yet + // TODO: this is an erroious path return false; }