diff options
| author | Wladimir J. van der Laan <[email protected]> | 2019-03-12 13:01:25 +0100 |
|---|---|---|
| committer | Wladimir J. van der Laan <[email protected]> | 2019-03-12 13:11:26 +0100 |
| commit | c3b1cb958f7c57c5d87db663f2b1a83e3471d354 (patch) | |
| tree | ba5906a28bf4a16a262b0805c3620b76a671a2c0 /src/util | |
| parent | Merge #15582: Fix overflow bug in analyzepsbt fee: CAmount instead of int (diff) | |
| parent | dead code: Remove dead option in HexStr conversion (diff) | |
| download | discoin-c3b1cb958f7c57c5d87db663f2b1a83e3471d354.tar.xz discoin-c3b1cb958f7c57c5d87db663f2b1a83e3471d354.zip | |
Merge #15573: dead code: Remove dead option in HexStr conversion
56f1d28d9b606397c0c746b57243a0f2b971ff8a 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
Diffstat (limited to 'src/util')
| -rw-r--r-- | src/util/strencodings.h | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/util/strencodings.h b/src/util/strencodings.h index cf7704409..7c4364a08 100644 --- a/src/util/strencodings.h +++ b/src/util/strencodings.h @@ -12,6 +12,7 @@ #include <attributes.h> #include <cstdint> +#include <iterator> #include <string> #include <vector> @@ -121,28 +122,25 @@ 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(std::distance(itbegin, itend) * 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]); } - return rv; } 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()); } /** |