Optimize json_escape_utf8 a bit by removing repeated calls to string methods

This commit is contained in:
Tim Wojtulewicz 2020-01-08 12:08:32 -07:00
parent ee0619f999
commit 23f551876c
2 changed files with 26 additions and 22 deletions

View file

@ -118,7 +118,7 @@ std::string extract_ip_and_len(const std::string& i, int* len);
inline void bytetohex(unsigned char byte, char* hex_out)
{
static const char hex_chars[] = "0123456789abcdef";
static constexpr char hex_chars[] = "0123456789abcdef";
hex_out[0] = hex_chars[(byte & 0xf0) >> 4];
hex_out[1] = hex_chars[byte & 0x0f];
}