From ac4e7f6269429b27f32d290df7e0572814e60068 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Sun, 9 Sep 2012 14:52:07 +0200 Subject: HexStr: don't build a vector first Also const correctness for lookup tables in hex functions throughout the code. --- src/util.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/util.h') 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 std::string HexStr(const T itbegin, const T itend, bool fSpaces=false) { - std::vector 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& vch, bool fSpaces=false) -- cgit v1.2.3