What changed, and why it matters
This commit is a small code cleanup in Bitcoin Core. It replaces a hand-written equality check for a custom vector-like container (`prevector`) with a standard C++ library function (`std::ranges::equal`). There is no security-relevant change visible in the diff, and no security context is provided by the commit or any supplied references.
No security action required. Treat as a normal code-quality/refactoring change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch refactors prevector::operator== in src/prevector.h. The previous implementation manually compared sizes and iterated over elements. The new implementation uses std::ranges::equal(*this, other) and marks the function constexpr. The behavior is functionally equivalent: both compare size and element-wise equality. No bounds, type, or logic changes that would introduce a vulnerability are present in the diff.
Changed components
src/prevector.hInspect captured patch +2 / −15
diff --git a/src/prevector.h b/src/prevector.h
index d4d90c73..91be4880 100644
--- a/src/prevector.h
+++ b/src/prevector.h
@@ -426,21 +426,8 @@ public:
}
}
- bool operator==(const prevector<N, T, Size, Diff>& other) const {
- if (other.size() != size()) {
- return false;
- }
- const_iterator b1 = begin();
- const_iterator b2 = other.begin();
- const_iterator e1 = end();
- while (b1 != e1) {
- if ((*b1) != (*b2)) {
- return false;
- }
- ++b1;
- ++b2;
- }
- return true;
+ constexpr bool operator==(const prevector& other) const {
+ return std::ranges::equal(*this, other);
}
bool operator<(const prevector<N, T, Size, Diff>& other) const {
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.