-
Notifications
You must be signed in to change notification settings - Fork 38.7k
prevector: simplify implementation of comparison operators and match behavior of std::vector
#33772
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code Coverage & BenchmarksFor details see: https://corecheck.dev/bitcoin/bitcoin/pulls/33772. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
|
As indicated by the CI, the macOS SDK we are targeting doesn't (yet) support In file included from /distsrc-base/distsrc-21318e8b5df5-arm64-apple-darwin/src/chainparams.cpp:6:
In file included from /distsrc-base/distsrc-21318e8b5df5-arm64-apple-darwin/src/chainparams.h:9:
In file included from /distsrc-base/distsrc-21318e8b5df5-arm64-apple-darwin/src/kernel/chainparams.h:11:
In file included from /distsrc-base/distsrc-21318e8b5df5-arm64-apple-darwin/src/primitives/block.h:9:
In file included from /distsrc-base/distsrc-21318e8b5df5-arm64-apple-darwin/src/primitives/transaction.h:12:
In file included from /distsrc-base/distsrc-21318e8b5df5-arm64-apple-darwin/src/script/script.h:11:
/distsrc-base/distsrc-21318e8b5df5-arm64-apple-darwin/src/prevector.h:446:21: error: no member named 'lexicographical_compare_three_way' in namespace 'std'; did you mean 'lexicographical_compare'?
446 | return std::lexicographical_compare_three_way(begin(), end(), other.begin(), other.end());
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| lexicographical_compare
/root/SDKs/Xcode-15.0-15A240d-extracted-SDK-with-libcxx-headers/usr/include/c++/v1/__algorithm/lexicographical_compare.h:42:1: note: 'lexicographical_compare' declared here
42 | lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1,
| ^ |
21318e8 to
f6f7adb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea, and it would be an improvement to both simplify the prevector implementation and move it closer to being a std::vector drop-in. However, the different operator< implementation has a lot of potential behaviour change (not just direct comparison such as in CNoDestination::operator<, but also in e.g. all maps and sets of CScript), and assuring myself the changes are safe is going to take more time than seems worth it for the stated benefits. So: Concept ACK, but Priority NACK for me.
|
🐙 This pull request conflicts with the target branch and needs rebase. |
The reduced amount of code reduces maintenance. Providing
prevector::operator<=>allows classes that are implemented in terms ofprevectorto use the compiler providedoperator<=>.However, there is a breaking change!
The old implementation claims to be a drop-in replacement for
std::vector. However, the implementation foroperator<is different when comparing two vectors of different length, as can be presented with the following code:With the old implementation of
prevector, the assertion fails. With my change, it passes.I ask the reviewers to confirm whether this change in behavior is acceptable or not.