-
Notifications
You must be signed in to change notification settings - Fork 38.7k
refactor: remove use of boost::algorithm::replace_first #20067
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
refactor: remove use of boost::algorithm::replace_first #20067
Conversation
|
Concept ACK Every step towards a Boost free future counts :) |
src/core_read.cpp
Outdated
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.
Wouldn't find instead of rfind make the code match the previous replace_first version 100%?
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.
Indeed, to match the previous version 100% the code would look something like this:
...
// Convenience: OP_ADD and just ADD are both recognized:
auto pos = strName.find("OP_");
if (pos != std::string::npos) {
strName = strName.substr(0, pos) + strName.substr(pos+3);
mapOpNames[strName] = static_cast<opcodetype>(op);
}
...That would also eliminate an "OP_" substring that is not at the start of strName. Don't know though if that really makes sense to match the previous version 100% (which did more than needed -- pos will always be either 0 or npos)? I guess it's a matter of taste and how strict a refactoring is defined.
|
mapOpNames wouldn't be written to if the name doesn't start with |
It is, the line above the comment isn't changed or removed by this PR: Lines 41 to 44 in 875e1cc
Nice idea, unfortunately only available since C++17... |
I think this refactor is low-prio enough, so that it can wait the 4 weeks until we have C++17 |
|
Nevermind, on a second look, the |
luke-jr
left a comment
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.
Concept NACK: Seems like a waste of time to review and fix. Boost isn't going anywhere any time soon, and that's okay.
This won't work with bare opcodes as-is.
The reason I opened this PR was that it was actively proposed by regular contributors (see e.g. #19851 (comment), #19851 (comment)). I also saw quite a lot of merged PRs within the last months that try to get rid of boost. Can you elaborate more on why you think getting rid of Boost is not worthwile?
Given that with "bare opcodes" you mean "opcodes not starting with 'OP_'": Those are put into the dictionary before the condition that is introduced by this patch. (If that wouldn't work, the tests would of course also fail.) |
fadc23d to
1a6b374
Compare
1a6b374 to
6f4e393
Compare
|
Rebased on master and followed luke-jrs suggestion, using the compare() method for checking the OP_ prefix rather than the less readable rfind(). |
|
Code review ACK 6f4e393 |
…e_first 6f4e393 refactor: remove use of boost::algorithm::replace_first (Sebastian Falbesoner) Pull request description: As discussed in bitcoin#19851 (bitcoin#19851 (comment)), this trivial PR substitutes the (only) use of `boost::algorithm::replace_first` by a direct implementation. ACKs for top commit: laanwj: Code review ACK 6f4e393 Tree-SHA512: 2ef06498e19f864a4cbae10e8d1905e3440a2d1e8e5aae83de7597c23cdab92b4612d7fa1efbc49016e530debd127d1d50531c60ff159dbea0deaa8c836a2bfb
…e_first 6f4e393 refactor: remove use of boost::algorithm::replace_first (Sebastian Falbesoner) Pull request description: As discussed in bitcoin#19851 (bitcoin#19851 (comment)), this trivial PR substitutes the (only) use of `boost::algorithm::replace_first` by a direct implementation. ACKs for top commit: laanwj: Code review ACK 6f4e393 Tree-SHA512: 2ef06498e19f864a4cbae10e8d1905e3440a2d1e8e5aae83de7597c23cdab92b4612d7fa1efbc49016e530debd127d1d50531c60ff159dbea0deaa8c836a2bfb
…e_first 6f4e393 refactor: remove use of boost::algorithm::replace_first (Sebastian Falbesoner) Pull request description: As discussed in bitcoin#19851 (bitcoin#19851 (comment)), this trivial PR substitutes the (only) use of `boost::algorithm::replace_first` by a direct implementation. ACKs for top commit: laanwj: Code review ACK 6f4e393 Tree-SHA512: 2ef06498e19f864a4cbae10e8d1905e3440a2d1e8e5aae83de7597c23cdab92b4612d7fa1efbc49016e530debd127d1d50531c60ff159dbea0deaa8c836a2bfb
merge bitcoin#13671, bitcoin#17405, bitcoin#18786, bitcoin#18792, bitcoin#20067: Deboostification
Summary: This is a backport of [[bitcoin/bitcoin#20067 | core#20067]] I remove a trivial comment, to avoid having two comments on the previous lines. Test Plan: `ninja all check-all` Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D10768
As discussed in #19851 (#19851 (comment)), this trivial PR substitutes the (only) use of
boost::algorithm::replace_firstby a direct implementation.