Problem:
- Nothing uses the
fspacesargument toHexStr()besides unit tests. This argument results in extra complexity and a small performance decrease within the function.
Solution:
- Remove unused
fspacesoption. - Remove associated unit tests.
Problem:
fspaces argument to HexStr() besides unit
tests. This argument results in extra complexity and a small
performance decrease within the function.Solution:
fspaces option.I wouldn’t call the performance difference worthwhile, but I’m all for removing dead code.
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?
Limited change to only removing dead code and updated PR details.
126 | {
127 | std::string rv;
128 | static const char hexmap[16] = { '0', '1', '2', '3', '4', '5', '6', '7',
129 | '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
130 | - rv.reserve((itend-itbegin)*3);
131 | + rv.reserve(std::distance(itbegin, itend) * 2);
#include <iterator>?
Thanks for noticing. Done.
Why in uint256.h?
I have no idea. Mix-up on my part. Fixed now.
<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
<!--174a7506f384e20aa4161008e828411d-->
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.
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.
utACK 56f1d28d9b606397c0c746b57243a0f2b971ff8a
-42 lines: very nice! Thanks for removing this cruft.
utACK 56f1d28