Skip to content

Commit b971354

Browse files
UdjinM6claude
andcommitted
fix: use native std::set::contains() instead of linear search
Use C++20's native `std::set::contains()` method for `forMembers` and `validCommitments` instead of `std23::ranges::contains()` which performs an O(n) linear scan. The native method maintains O(log n) complexity. Also removes the now-unused `<util/std23.h>` include from the file. Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent dc28b5d commit b971354

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/active/dkgsession.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include <llmq/utils.h>
1414
#include <masternode/meta.h>
1515
#include <util/helpers.h>
16-
#include <util/std23.h>
1716

1817
#include <chain.h>
1918
#include <deploymentstatus.h>
@@ -356,7 +355,7 @@ void ActiveDKGSession::SendJustification(CDKGPendingMessages& pendingMessages, P
356355

357356
for (const uint32_t i : util::irange(members.size())) {
358357
const auto& m = members[i];
359-
if (!std23::ranges::contains(forMembers, m->dmn->proTxHash)) {
358+
if (!forMembers.contains(m->dmn->proTxHash)) {
360359
continue;
361360
}
362361
logger.Batch("justifying for %s", m->dmn->proTxHash.ToString());
@@ -561,7 +560,7 @@ std::vector<CFinalCommitment> ActiveDKGSession::FinalizeCommitments()
561560

562561
for (const auto& p : prematureCommitments) {
563562
const auto& qc = p.second;
564-
if (!std23::ranges::contains(validCommitments, p.first)) {
563+
if (!validCommitments.contains(p.first)) {
565564
continue;
566565
}
567566

0 commit comments

Comments
 (0)