Skip to content

Commit

Permalink
Update hexify to use array lookup instead of ternary (#270)
Browse files Browse the repository at this point in the history
  • Loading branch information
dtoma committed Jun 29, 2016
1 parent 7ffa07e commit 5c129c8
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/json.hpp.re2c
Original file line number Diff line number Diff line change
Expand Up @@ -5959,9 +5959,11 @@ class basic_json
// (0..f)
const auto hexify = [](const int v) -> char
{
return (v < 10)
? ('0' + static_cast<char>(v))
: ('a' + static_cast<char>((v - 10) & 0x1f));
static const char hex[16] = { '0', '1', '2', '3',
'4', '5', '6', '7',
'8', '9', 'a', 'b',
'c', 'd', 'e', 'f' };
return hex[v];
};

// print character c as \uxxxx
Expand Down

0 comments on commit 5c129c8

Please sign in to comment.