mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 21:12:48 +01:00
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.
This commit is contained in:
parent
6206252e50
commit
0a177148e7
@ -20,10 +20,7 @@ base_blob<BITS>::base_blob(const std::vector<unsigned char>& vch)
|
|||||||
template <unsigned int BITS>
|
template <unsigned int BITS>
|
||||||
std::string base_blob<BITS>::GetHex() const
|
std::string base_blob<BITS>::GetHex() const
|
||||||
{
|
{
|
||||||
char psz[sizeof(data) * 2 + 1];
|
return HexStr(std::reverse_iterator<const uint8_t*>(data + sizeof(data)), std::reverse_iterator<const uint8_t*>(data));
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <unsigned int BITS>
|
template <unsigned int BITS>
|
||||||
|
Loading…
Reference in New Issue
Block a user