mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 06:58:57 +01:00
refactor: Make HexStr take a span
Make HexStr take a span of bytes, instead of an awkward pair of templated iterators.
This commit is contained in:
@@ -569,3 +569,16 @@ std::string Capitalize(std::string str)
|
||||
str[0] = ToUpper(str.front());
|
||||
return str;
|
||||
}
|
||||
|
||||
std::string HexStr(const Span<const uint8_t> s)
|
||||
{
|
||||
std::string rv;
|
||||
static constexpr char hexmap[16] = { '0', '1', '2', '3', '4', '5', '6', '7',
|
||||
'8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
|
||||
rv.reserve(s.size() * 2);
|
||||
for (uint8_t v: s) {
|
||||
rv.push_back(hexmap[v >> 4]);
|
||||
rv.push_back(hexmap[v & 15]);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user