-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Remove the boost/algorithm/string/predicate.hpp dependency #13656
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
Remove the boost/algorithm/string/predicate.hpp dependency #13656
Conversation
utACK 6285655d9592bf684f2ddc69871456fb3628b8a6 |
utACK 6285655 |
Concept ACK After this change there are only a few other uses of If you do, please also remove starts_withLine 57 in 8803c91
Line 63 in 8803c91
Line 69 in 8803c91
bitcoin/src/wallet/rpcdump.cpp Line 588 in 8803c91
bitcoin/src/wallet/rpcdump.cpp Line 594 in 8803c91
ends_withLine 69 in 8803c91
|
Could follow @fanquake's suggestion for just the single-character checks. |
Note to reviewers: 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. |
@251labs depends on circumstances and the fix, but dealing with all identical cases in a single PR can help minimize review effort to avoid splitting consideration and discussion over multiple PRs. Even better would be to lint against single-char starts_with/ends_with, to prevent future introduction, but I doubt that's worthwhile in this case. |
e1c3061
to
522203e
Compare
Thanks for the clarification @Empact. I have updated the PR and changed the title and description accordingly. |
src/utilstrencodings.cpp
Outdated
@@ -425,6 +425,11 @@ int atoi(const std::string& str) | |||
return atoi(str.c_str()); | |||
} | |||
|
|||
bool IsDigit(char c) |
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.
nit: constexpr
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.
Nice one @Empact, addressed in 2a02b4a.
nit: There are 5 places in Note the other possible uses are in included projects, e..g leveldb, tinyformat, which shouldn't be changed. |
cb90b20
to
146793c
Compare
Thanks again @Empact , I have addressed your feedback in 2a02b4a. |
utACK 146793c nit: could squash |
Thanks @Empact, I am happy to squash this. Just wanted to let you know that 2a02b4a is an atomic commit on its own. Strictly speaking the work in 2a02b4a was not required to drop the predicate dependency in 146793c. Maybe a squashed commit would be confusing from that POV (particularly in a limited blame- or history view). Either way, I am happy to squash this. Please let me know what is preferred and I will take it from there :) |
Could go either way, but IMO neither is so complicated that they don't bear combination, and the latter motivates the former. |
utACK 146793caa9403310ae44d1f7fa54dc077d4b2d39 |
src/core_read.cpp
Outdated
{ | ||
// Number | ||
int64_t n = atoi64(*w); | ||
result << n; | ||
} | ||
else if (boost::algorithm::starts_with(*w, "0x") && (w->begin()+2 != w->end()) && IsHex(std::string(w->begin()+2, w->end()))) | ||
else if (w->substr(0,2) == "0x" && (w->begin()+2 < w->end()) && IsHex(std::string(w->begin()+2, w->end()))) |
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.
unrelated nit: could use std::string::size > 2
here
utACK 146793caa9403310ae44d1f7fa54dc077d4b2d39 |
146793c
to
ddd4e80
Compare
This is a squashed commit that squashes the following commits: This commit removes the `boost/algorithm/string/predicate.hpp` dependenc from the project by replacing the function calls to `boost::algorithm::starts_with` `boost::algorithm::ends_with` and `all` with respectively C++11' `std::basic_string::front`, `std::basic_string::back`, `std::all_of` function calls This commit replaces `boost::algorithm::is_digit` with a locale independent isdigi function, because the use of the standard library's `isdigit` and `std::isdigit functions is discoraged in the developer notes
ddd4e80
to
e3245f2
Compare
Thanks for the reviews! Not sure if it is appreciated if nits are addressed following utACKs, but e3245f2 addresses @MarcoFalke's nit #13656 (comment); squashes individual commits per @Empact's feedback; and is rebased on master (0a34593). |
utACK e3245f2 |
re-utACK e3245f2 |
e3245f2 Removes Boost predicate.hpp dependency (251) Pull request description: This pull request removes the `boost/algorithm/string/predicate.hpp` dependency from the project. To replace the the `predicate.hpp` dependency from the project the function calls to `boost::algorithm::starts_with` and `boost::algorithm::ends_with` have been replaced with respectively C++11's `std::basic_string::front` and `std::basic_string::back` function calls. Refactors that were not required, but have been done anyways: - The Boost function `all` was implicitly made available via the `predicate.hpp` header. Instead of including the appropriate header, function calls to `all` have been replaced with function calls to `std::all_of`. - The `boost::algorithm::is_digit` predicate has been replaced with a custom `IsDigit` function that is locale independent and ASCII deterministic. Tree-SHA512: 22dda6adfb4d7ac0cabac8cc33e8fb8330c899805acc1ae4ede402c4b11ea75a399414b389dfaa3650d23b47f41351b4650077af9005d598fbe48d5277bdc320
Summary: e3245f2 Removes Boost predicate.hpp dependency (251) Pull request description: This pull request removes the `boost/algorithm/string/predicate.hpp` dependency from the project. To replace the the `predicate.hpp` dependency from the project the function calls to `boost::algorithm::starts_with` and `boost::algorithm::ends_with` have been replaced with respectively C++11's `std::basic_string::front` and `std::basic_string::back` function calls. Refactors that were not required, but have been done anyways: - The Boost function `all` was implicitly made available via the `predicate.hpp` header. Instead of including the appropriate header, function calls to `all` have been replaced with function calls to `std::all_of`. - The `boost::algorithm::is_digit` predicate has been replaced with a custom `IsDigit` function that is locale independent and ASCII deterministic. Tree-SHA512: 22dda6adfb4d7ac0cabac8cc33e8fb8330c899805acc1ae4ede402c4b11ea75a399414b389dfaa3650d23b47f41351b4650077af9005d598fbe48d5277bdc320 Backport of Core PR13656 bitcoin/bitcoin#13656 Test Plan: make check Undo the change to the linter script arc lint --everything Should output: Advice (BOOST_DEPENDENCY) Good job! A boost dependency has been removed. Good job! The Boost dependency "boost/algorithm/string/predicate.hpp" is no longer used. Please remove it from EXPECTED_BOOST_INCLUDES in <path>/bitcoin-abc/test/lint/lint-boost-dependencies.sh to make sure this dependency is not accidentally reintroduced. Reviewers: deadalnix, Fabien, jasonbcox, O1 Bitcoin ABC, #bitcoin_abc, markblundeberg Reviewed By: O1 Bitcoin ABC, #bitcoin_abc, markblundeberg Subscribers: markblundeberg Differential Revision: https://reviews.bitcoinabc.org/D4727
…dependency e3245f2 Removes Boost predicate.hpp dependency (251) Pull request description: This pull request removes the `boost/algorithm/string/predicate.hpp` dependency from the project. To replace the the `predicate.hpp` dependency from the project the function calls to `boost::algorithm::starts_with` and `boost::algorithm::ends_with` have been replaced with respectively C++11's `std::basic_string::front` and `std::basic_string::back` function calls. Refactors that were not required, but have been done anyways: - The Boost function `all` was implicitly made available via the `predicate.hpp` header. Instead of including the appropriate header, function calls to `all` have been replaced with function calls to `std::all_of`. - The `boost::algorithm::is_digit` predicate has been replaced with a custom `IsDigit` function that is locale independent and ASCII deterministic. Tree-SHA512: 22dda6adfb4d7ac0cabac8cc33e8fb8330c899805acc1ae4ede402c4b11ea75a399414b389dfaa3650d23b47f41351b4650077af9005d598fbe48d5277bdc320
…dependency e3245f2 Removes Boost predicate.hpp dependency (251) Pull request description: This pull request removes the `boost/algorithm/string/predicate.hpp` dependency from the project. To replace the the `predicate.hpp` dependency from the project the function calls to `boost::algorithm::starts_with` and `boost::algorithm::ends_with` have been replaced with respectively C++11's `std::basic_string::front` and `std::basic_string::back` function calls. Refactors that were not required, but have been done anyways: - The Boost function `all` was implicitly made available via the `predicate.hpp` header. Instead of including the appropriate header, function calls to `all` have been replaced with function calls to `std::all_of`. - The `boost::algorithm::is_digit` predicate has been replaced with a custom `IsDigit` function that is locale independent and ASCII deterministic. Tree-SHA512: 22dda6adfb4d7ac0cabac8cc33e8fb8330c899805acc1ae4ede402c4b11ea75a399414b389dfaa3650d23b47f41351b4650077af9005d598fbe48d5277bdc320
…dependency e3245f2 Removes Boost predicate.hpp dependency (251) Pull request description: This pull request removes the `boost/algorithm/string/predicate.hpp` dependency from the project. To replace the the `predicate.hpp` dependency from the project the function calls to `boost::algorithm::starts_with` and `boost::algorithm::ends_with` have been replaced with respectively C++11's `std::basic_string::front` and `std::basic_string::back` function calls. Refactors that were not required, but have been done anyways: - The Boost function `all` was implicitly made available via the `predicate.hpp` header. Instead of including the appropriate header, function calls to `all` have been replaced with function calls to `std::all_of`. - The `boost::algorithm::is_digit` predicate has been replaced with a custom `IsDigit` function that is locale independent and ASCII deterministic. Tree-SHA512: 22dda6adfb4d7ac0cabac8cc33e8fb8330c899805acc1ae4ede402c4b11ea75a399414b389dfaa3650d23b47f41351b4650077af9005d598fbe48d5277bdc320
This pull request removes the
boost/algorithm/string/predicate.hpp
dependency from the project.To replace the the
predicate.hpp
dependency from the project the function calls toboost::algorithm::starts_with
andboost::algorithm::ends_with
have been replaced with respectively C++11'sstd::basic_string::front
andstd::basic_string::back
function calls.Refactors that were not required, but have been done anyways:
The Boost function
all
was implicitly made available via thepredicate.hpp
header. Instead of including the appropriate header, function calls toall
have been replaced with function calls tostd::all_of
.The
boost::algorithm::is_digit
predicate has been replaced with a customIsDigit
function that is locale independent and ASCII deterministic.