Skip to content

Commit

Permalink
fixes #270
Browse files Browse the repository at this point in the history
  • Loading branch information
nlohmann committed Jul 1, 2016
1 parent 814fb31 commit 6e1347e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,7 @@ I deeply appreciate the help of the following people.
- [Tom Needham](https://github.com/06needhamt) fixed a subtle bug with MSVC 2015 which was also proposed by [Michael K.](https://github.com/Epidal).
- [Mário Feroldi](https://github.com/thelostt) fixed a small typo.
- [duncanwerner](https://github.com/duncanwerner) found a really embarrassing performance regression in the 2.0.0 release.
- [Damien](https://github.com/dtoma) fixed one of the last conversion warnings.
Thanks a lot for helping out!
Expand Down
9 changes: 4 additions & 5 deletions src/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5957,16 +5957,15 @@ class basic_json
{
// convert a number 0..15 to its hex representation
// (0..f)
const auto hexify = [](const int v) -> char
static const char hexify[16] =
{
return (v < 10)
? ('0' + static_cast<char>(v))
: ('a' + static_cast<char>((v - 10) & 0x1f));
'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'a', 'b', 'c', 'd', 'e', 'f'
};

// print character c as \uxxxx
for (const char m :
{ 'u', '0', '0', hexify(c >> 4), hexify(c & 0x0f)
{ 'u', '0', '0', hexify[c >> 4], hexify[c & 0x0f]
})
{
result[++pos] = m;
Expand Down
11 changes: 4 additions & 7 deletions src/json.hpp.re2c
Original file line number Diff line number Diff line change
Expand Up @@ -5957,18 +5957,15 @@ class basic_json
{
// convert a number 0..15 to its hex representation
// (0..f)
const auto hexify = [](const int v) -> char
static const char hexify[16] =
{
static const char hex[16] = { '0', '1', '2', '3',
'4', '5', '6', '7',
'8', '9', 'a', 'b',
'c', 'd', 'e', 'f' };
return hex[v];
'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'a', 'b', 'c', 'd', 'e', 'f'
};

// print character c as \uxxxx
for (const char m :
{ 'u', '0', '0', hexify(c >> 4), hexify(c & 0x0f)
{ 'u', '0', '0', hexify[c >> 4], hexify[c & 0x0f]
})
{
result[++pos] = m;
Expand Down

0 comments on commit 6e1347e

Please sign in to comment.