dead code: Remove dead option in HexStr conversion#15573
dead code: Remove dead option in HexStr conversion#15573laanwj merged 1 commit intobitcoin:masterfrom
Conversation
|
I wouldn’t call the performance difference worthwhile, but I’m all for removing dead code. |
There was a problem hiding this comment.
Concept ACK, if it's not used then it can be removed.
I don't think the performance gain justifies this change. Anyway, I think the following is enough:
--- a/src/util/strencodings.h
+++ b/src/util/strencodings.h
@@ -121,17 +121,15 @@ NODISCARD bool ParseUInt64(const std::string& str, uint64_t *out);
NODISCARD bool ParseDouble(const std::string& str, double *out);
template<typename T>
-std::string HexStr(const T itbegin, const T itend, bool fSpaces=false)
+std::string HexStr(const T itbegin, const T itend)
{
std::string rv;
static const char hexmap[16] = { '0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
- rv.reserve((itend-itbegin)*3);
+ rv.reserve((itend-itbegin) * 2);
for(T it = itbegin; it < itend; ++it)
{
unsigned char val = (unsigned char)(*it);
- if(fSpaces && it != itbegin)
- rv.push_back(' ');
rv.push_back(hexmap[val>>4]);
rv.push_back(hexmap[val&15]);
}
@@ -140,9 +138,9 @@ std::string HexStr(const T itbegin, const T itend, bool fSpaces=false)
}
template<typename T>
-inline std::string HexStr(const T& vch, bool fSpaces=false)
+inline std::string HexStr(const T& vch)
{
- return HexStr(vch.begin(), vch.end(), fSpaces);
+ return HexStr(vch.begin(), vch.end());
}
/**|
HexStr does not in any way affect the Base58 benchmarks, I think? |
3ee66cd to
24a9efe
Compare
|
Limited change to only removing dead code and updated PR details. |
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. 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. |
24a9efe to
3618979
Compare
Problem: - Nothing uses the `fspaces` argument to `HexStr()` besides unit tests. This argument results in extra complexity and a small performance decrease within the function for branch evalulation. Solution: - Remove unused `fspaces` option.
3618979 to
56f1d28
Compare
|
utACK 56f1d28 |
|
utACK 56f1d28 -42 lines: very nice! Thanks for removing this cruft. |
|
utACK 56f1d28 |
56f1d28 dead code: Remove dead option in HexStr conversion (Lenny Maiorani) Pull request description: Problem: - Nothing uses the `fspaces` argument to `HexStr()` besides unit tests. This argument results in extra complexity and a small performance decrease within the function. Solution: - Remove unused `fspaces` option. - Remove associated unit tests. Tree-SHA512: 33d00ce354bbc62a77232fa301cdef0a9ed2c5a09e792bc40e9620c2f2f88636e322a38c76b81d10d12a1768dd1b3b2b9cf180f7e33daef9b4f27afed68ccf70
Summary: Problem: - Nothing uses the `fspaces` argument to `HexStr()` besides unit tests. This argument results in extra complexity and a small performance decrease within the function for branch evalulation. Solution: - Remove unused `fspaces` option. Backport of Core [[bitcoin/bitcoin#15573 | PR15573]] Test Plan: `grep -r 'HexStr([^,]*,[^,]*,' src/` `ninja all check-all` Reviewers: O1 Bitcoin ABC, #bitcoin_abc, deadalnix Reviewed By: O1 Bitcoin ABC, #bitcoin_abc, deadalnix Subscribers: deadalnix Differential Revision: https://reviews.bitcoinabc.org/D7738
d4408cd Make HexStr() take a Span (furszy) 4c755ec dead code: Remove dead option in HexStr conversion. (Lenny Maiorani) Pull request description: Follow up to #2470. Only the last two commits are from this work. Make `HexStr` take a span of bytes, instead of an awkward pair of templated iterators. Simplifying most of the uses. Adaptation of bitcoin#19660 and bitcoin#15573. ACKs for top commit: random-zebra: utACK d4408cd Tree-SHA512: 541f80e1af9abea2d662e5fc31fc4d5b4057ff93eefeba5632c6ddca391f3b148c8d819a56802720c3932c3c2afb69ddd1efb4890a59ecf1bf5afd6686cd5a67
Problem:
fspacesargument toHexStr()besides unittests. This argument results in extra complexity and a small
performance decrease within the function.
Solution:
fspacesoption.