mirror of
https://github.com/nlohmann/json.git
synced 2024-08-23 21:42:29 +02:00
Update hexify to use array lookup instead of ternary (#270)
This commit is contained in:
parent
7ffa07e3a3
commit
5c129c8981
|
@ -5959,9 +5959,11 @@ class basic_json
|
||||||
// (0..f)
|
// (0..f)
|
||||||
const auto hexify = [](const int v) -> char
|
const auto hexify = [](const int v) -> char
|
||||||
{
|
{
|
||||||
return (v < 10)
|
static const char hex[16] = { '0', '1', '2', '3',
|
||||||
? ('0' + static_cast<char>(v))
|
'4', '5', '6', '7',
|
||||||
: ('a' + static_cast<char>((v - 10) & 0x1f));
|
'8', '9', 'a', 'b',
|
||||||
|
'c', 'd', 'e', 'f' };
|
||||||
|
return hex[v];
|
||||||
};
|
};
|
||||||
|
|
||||||
// print character c as \uxxxx
|
// print character c as \uxxxx
|
||||||
|
|
Loading…
Reference in a new issue