Fix clang-tidy avoid-c-arrays warning in write_u_escape

Use a const char* rather than a char[] lookup table, matching the
existing hex_bytes helper in the same file.

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
Niels Lohmann
2026-07-04 23:06:45 +02:00
parent 4cad4e08a4
commit ce576f6316
2 changed files with 2 additions and 2 deletions
@@ -694,7 +694,7 @@ class serializer
std::size_t write_u_escape(std::size_t pos, std::uint16_t codeunit) noexcept
{
JSON_ASSERT(string_buffer.size() - pos >= 6);
static constexpr const char nibble_to_hex[] = "0123456789abcdef";
constexpr const char* nibble_to_hex = "0123456789abcdef";
string_buffer[pos + 0] = '\\';
string_buffer[pos + 1] = 'u';
string_buffer[pos + 2] = nibble_to_hex[(codeunit >> 12u) & 0x0Fu];
+1 -1
View File
@@ -19981,7 +19981,7 @@ class serializer
std::size_t write_u_escape(std::size_t pos, std::uint16_t codeunit) noexcept
{
JSON_ASSERT(string_buffer.size() - pos >= 6);
static constexpr const char nibble_to_hex[] = "0123456789abcdef";
constexpr const char* nibble_to_hex = "0123456789abcdef";
string_buffer[pos + 0] = '\\';
string_buffer[pos + 1] = 'u';
string_buffer[pos + 2] = nibble_to_hex[(codeunit >> 12u) & 0x0Fu];