aboutsummaryrefslogtreecommitdiff
path: root/src/uint256.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2017-02-27 07:43:37 +0100
committerWladimir J. van der Laan <laanwj@gmail.com>2017-02-27 10:02:45 +0100
commit0a177148e7dbac2e88ddc142f0ef10c6a4de8ec8 (patch)
treefa494a94a4bcd03d5138d5047b22c22e1b93a430 /src/uint256.cpp
parent6206252e5073c1cde2e313f2e5a3ca17582c5823 (diff)
uint256: replace sprintf with HexStr and reverse-iterator
Instead of calling sprintf for every byte, format the hex bytes ourselves by help of HexStr and a reverse_iterator.
Diffstat (limited to 'src/uint256.cpp')
-rw-r--r--src/uint256.cpp5
1 files changed, 1 insertions, 4 deletions
diff --git a/src/uint256.cpp b/src/uint256.cpp
index bd3d017085..c4c7b716fe 100644
--- a/src/uint256.cpp
+++ b/src/uint256.cpp
@@ -20,10 +20,7 @@ base_blob<BITS>::base_blob(const std::vector<unsigned char>& vch)
template <unsigned int BITS>
std::string base_blob<BITS>::GetHex() const
{
- char psz[sizeof(data) * 2 + 1];
- for (unsigned int i = 0; i < sizeof(data); i++)
- sprintf(psz + i * 2, "%02x", data[sizeof(data) - i - 1]);
- return std::string(psz, psz + sizeof(data) * 2);
+ return HexStr(std::reverse_iterator<const uint8_t*>(data + sizeof(data)), std::reverse_iterator<const uint8_t*>(data));
}
template <unsigned int BITS>