Skip to content

Commit 0a17714

Browse files
committed
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.
1 parent 6206252 commit 0a17714

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

src/uint256.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@ base_blob<BITS>::base_blob(const std::vector<unsigned char>& vch)
2020
template <unsigned int BITS>
2121
std::string base_blob<BITS>::GetHex() const
2222
{
23-
char psz[sizeof(data) * 2 + 1];
24-
for (unsigned int i = 0; i < sizeof(data); i++)
25-
sprintf(psz + i * 2, "%02x", data[sizeof(data) - i - 1]);
26-
return std::string(psz, psz + sizeof(data) * 2);
23+
return HexStr(std::reverse_iterator<const uint8_t*>(data + sizeof(data)), std::reverse_iterator<const uint8_t*>(data));
2724
}
2825

2926
template <unsigned int BITS>

0 commit comments

Comments
 (0)