diff options
author | Lenny Maiorani <lenny@colorado.edu> | 2019-03-10 11:37:05 -0600 |
---|---|---|
committer | Lenny Maiorani <lenny@colorado.edu> | 2019-03-10 21:45:31 -0600 |
commit | 56f1d28d9b606397c0c746b57243a0f2b971ff8a (patch) | |
tree | 73b5b16e21e232842f3cc38ebee281653c61535a /src/util | |
parent | 257f750cd986641afe04316ed0b22b646b56b60b (diff) |
dead code: Remove dead option in HexStr conversion
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.
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 cf77044094..7c4364a082 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()); } /** |