changeset 26737:a181f9379d42

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.
author Wladimir J. van der Laan <laanwj@gmail.com>
date Mon, 27 Feb 2017 07:43:37 +0100
parents dc409b41e670
children 4c58e442fc2c
files src/uint256.cpp
diffstat 1 files changed, 1 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/uint256.cpp	Sat Feb 25 10:43:16 2017 +0100
+++ b/src/uint256.cpp	Mon Feb 27 07:43:37 2017 +0100
@@ -20,10 +20,7 @@
 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>