From a9ebaa2c2fe1dc13a8e4c974d4349a1a51d584d1 Mon Sep 17 00:00:00 2001 From: Green Sky Date: Thu, 9 Jan 2025 01:53:17 +0100 Subject: [PATCH] improve perf (was ~.7% with asan enabled) --- solanaceae/ngc_ft1_sha1/sha1_ngcft1.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/solanaceae/ngc_ft1_sha1/sha1_ngcft1.cpp b/solanaceae/ngc_ft1_sha1/sha1_ngcft1.cpp index 3b0ca29..431bb11 100644 --- a/solanaceae/ngc_ft1_sha1/sha1_ngcft1.cpp +++ b/solanaceae/ngc_ft1_sha1/sha1_ngcft1.cpp @@ -989,7 +989,16 @@ bool SHA1_NGCFT1::onEvent(const Events::NGCFT1_recv_data& e) { } } - auto c = _tcm.getContactGroupPeer(e.group_number, e.peer_number); + Contact3Handle c; + const auto tpcc_it = _tox_peer_to_contact.find(combine_ids(e.group_number, e.peer_number)); + if (tpcc_it != _tox_peer_to_contact.cend()) { + c = tpcc_it->second; + } else { + c = _tcm.getContactGroupPeer(e.group_number, e.peer_number); + if (static_cast(c)) { + _tox_peer_to_contact[combine_ids(e.group_number, e.peer_number)] = c; + } + } if (static_cast(c)) { o.get_or_emplace() .tally[c]