aboutsummaryrefslogtreecommitdiff
path: root/src/util.h
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2012-09-09 14:52:07 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2012-09-10 04:24:57 +0200
commitac4e7f6269429b27f32d290df7e0572814e60068 (patch)
tree0ca4752c88b1f74ac4c1a9f3f65d4dae41600a6a /src/util.h
parent963af6449f3fbbb3f9fd79547a33e4f3d5e3f0d0 (diff)
HexStr: don't build a vector<char> first
Also const correctness for lookup tables in hex functions throughout the code.
Diffstat (limited to 'src/util.h')
-rw-r--r--src/util.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/util.h b/src/util.h
index 90df4efa3b..4b0814c6d3 100644
--- a/src/util.h
+++ b/src/util.h
@@ -256,9 +256,9 @@ inline int64 abs64(int64 n)
template<typename T>
std::string HexStr(const T itbegin, const T itend, bool fSpaces=false)
{
- std::vector<char> rv;
- static char hexmap[16] = { '0', '1', '2', '3', '4', '5', '6', '7',
- '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
+ 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);
for(T it = itbegin; it < itend; ++it)
{
@@ -269,7 +269,7 @@ std::string HexStr(const T itbegin, const T itend, bool fSpaces=false)
rv.push_back(hexmap[val&15]);
}
- return std::string(rv.begin(), rv.end());
+ return rv;
}
inline std::string HexStr(const std::vector<unsigned char>& vch, bool fSpaces=false)