Drop unneeded NOLINTs and reuse the pointer from utf8_dfa_prefix()
The check cppcoreguidelines-avoid-non-const-global-variables is disabled in .clang-tidy, and both tables are function-local constants. In valid_utf8_prefix(), test the byte through the returned pointer instead of indexing data again. Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
2 files changed
+10
-8
No files matched your search
Generated
+5
-4
@@ -13191,7 +13191,7 @@ unit-class_lexer.cpp checks every entry of the table.
|
||||
*/
|
||||
inline const std::uint64_t* utf8_dfa_table() noexcept
|
||||
{
|
||||
static const std::array<std::uint64_t, 256> table = // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
static const std::array<std::uint64_t, 256> table =
|
||||
{
|
||||
{
|
||||
0x0000000000000180ull, 0x0000000000000180ull, 0x0000000000000180ull, 0x0000000000000180ull,
|
||||
@@ -13350,8 +13350,9 @@ inline std::size_t valid_utf8_prefix(const unsigned char* data, std::size_t n) n
|
||||
continue;
|
||||
}
|
||||
|
||||
pos = static_cast<std::size_t>(utf8_dfa_prefix(data + pos, data + n) - data);
|
||||
if (pos != n && data[pos] >= 0x80u)
|
||||
const unsigned char* const last = utf8_dfa_prefix(data + pos, data + n);
|
||||
pos = static_cast<std::size_t>(last - data);
|
||||
if (pos != n && *last >= 0x80u)
|
||||
{
|
||||
break; // ill-formed or truncated
|
||||
}
|
||||
@@ -13651,7 +13652,7 @@ JSON_HEDLEY_ALWAYS_INLINE std::size_t lexer_string_bulk_run(const unsigned char*
|
||||
// unaffected by this fast path.
|
||||
inline int hex_codepoint(const unsigned char* data) noexcept
|
||||
{
|
||||
static const std::array<std::uint8_t, 256> hex_digit_table = // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
static const std::array<std::uint8_t, 256> hex_digit_table =
|
||||
{
|
||||
{
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 00..0F
|
||||
|
||||
Reference in new issue
Block a user