mirror of
https://github.com/nlohmann/json.git
synced 2026-07-21 19:23:03 +04:00
Satisfy clang-tidy: parenthesize math and drop unused forwarding reference
The CI clang-tidy (newer than the locally available version) reported two additional checks on the new code: - readability-math-missing-parentheses: parenthesize the (a * b) + c digit accumulations in number_parse.hpp. - cppcoreguidelines-missing-std-forward: the contiguous-byte-container input_adapter overload took a forwarding reference but only reads data()/size() and never forwards it. It is already disjoint from the generic container overload via SFINAE, so a plain const& is correct and clearer (and keeps the container alive for the whole parse just as before). No behavior change; char_type and routing are unchanged (std::string and std::vector<std::uint8_t> still take the pointer adapter with char/uint8_t char_type), CBOR/MsgPack round-trips and the 2M number fuzz still pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AXcDtEma2PjxgmPS9cQGzA Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
@@ -658,7 +658,7 @@ typename container_input_adapter_factory_impl::container_input_adapter_factory<C
|
||||
// iterators it replaces did.
|
||||
template < typename ContainerType,
|
||||
enable_if_t < is_contiguous_byte_container<ContainerType>::value, int > = 0 >
|
||||
auto input_adapter(ContainerType && container)
|
||||
auto input_adapter(const ContainerType& container)
|
||||
-> decltype(input_adapter(container.data(), container.data() + container.size()))
|
||||
{
|
||||
return input_adapter(container.data(), container.data() + container.size());
|
||||
|
||||
@@ -54,7 +54,7 @@ bool parse_integer_unsigned(const char* first, const char* last, NumberUnsignedT
|
||||
{
|
||||
return false;
|
||||
}
|
||||
x = x * 10u + digit;
|
||||
x = (x * 10u) + digit;
|
||||
}
|
||||
value = static_cast<NumberUnsignedType>(x);
|
||||
// reject values that do not round-trip into a narrower NumberUnsignedType
|
||||
@@ -84,7 +84,7 @@ bool parse_integer_signed(const char* first, const char* last, NumberIntegerType
|
||||
{
|
||||
return false;
|
||||
}
|
||||
magnitude = magnitude * 10u + digit;
|
||||
magnitude = (magnitude * 10u) + digit;
|
||||
}
|
||||
const std::int64_t x = (magnitude == limit)
|
||||
? (std::numeric_limits<std::int64_t>::min)()
|
||||
@@ -146,7 +146,7 @@ bool parse_float_fast(const char* first, const char* last, DecimalPointType deci
|
||||
{
|
||||
return false; // significand may not fit into uint64_t
|
||||
}
|
||||
significand = significand * 10u + static_cast<std::uint64_t>(c - '0');
|
||||
significand = (significand * 10u) + static_cast<std::uint64_t>(c - '0');
|
||||
++num_digits;
|
||||
fractional_digits += static_cast<int>(seen_dot);
|
||||
}
|
||||
@@ -189,7 +189,7 @@ bool parse_float_fast(const char* first, const char* last, DecimalPointType deci
|
||||
{
|
||||
return false;
|
||||
}
|
||||
exponent = exponent * 10 + (*p - '0');
|
||||
exponent = (exponent * 10) + (*p - '0');
|
||||
any_exp_digit = true;
|
||||
if (JSON_HEDLEY_UNLIKELY(exponent > 9999))
|
||||
{
|
||||
|
||||
@@ -7645,7 +7645,7 @@ typename container_input_adapter_factory_impl::container_input_adapter_factory<C
|
||||
// iterators it replaces did.
|
||||
template < typename ContainerType,
|
||||
enable_if_t < is_contiguous_byte_container<ContainerType>::value, int > = 0 >
|
||||
auto input_adapter(ContainerType && container)
|
||||
auto input_adapter(const ContainerType& container)
|
||||
-> decltype(input_adapter(container.data(), container.data() + container.size()))
|
||||
{
|
||||
return input_adapter(container.data(), container.data() + container.size());
|
||||
@@ -7837,7 +7837,7 @@ bool parse_integer_unsigned(const char* first, const char* last, NumberUnsignedT
|
||||
{
|
||||
return false;
|
||||
}
|
||||
x = x * 10u + digit;
|
||||
x = (x * 10u) + digit;
|
||||
}
|
||||
value = static_cast<NumberUnsignedType>(x);
|
||||
// reject values that do not round-trip into a narrower NumberUnsignedType
|
||||
@@ -7867,7 +7867,7 @@ bool parse_integer_signed(const char* first, const char* last, NumberIntegerType
|
||||
{
|
||||
return false;
|
||||
}
|
||||
magnitude = magnitude * 10u + digit;
|
||||
magnitude = (magnitude * 10u) + digit;
|
||||
}
|
||||
const std::int64_t x = (magnitude == limit)
|
||||
? (std::numeric_limits<std::int64_t>::min)()
|
||||
@@ -7929,7 +7929,7 @@ bool parse_float_fast(const char* first, const char* last, DecimalPointType deci
|
||||
{
|
||||
return false; // significand may not fit into uint64_t
|
||||
}
|
||||
significand = significand * 10u + static_cast<std::uint64_t>(c - '0');
|
||||
significand = (significand * 10u) + static_cast<std::uint64_t>(c - '0');
|
||||
++num_digits;
|
||||
fractional_digits += static_cast<int>(seen_dot);
|
||||
}
|
||||
@@ -7972,7 +7972,7 @@ bool parse_float_fast(const char* first, const char* last, DecimalPointType deci
|
||||
{
|
||||
return false;
|
||||
}
|
||||
exponent = exponent * 10 + (*p - '0');
|
||||
exponent = (exponent * 10) + (*p - '0');
|
||||
any_exp_digit = true;
|
||||
if (JSON_HEDLEY_UNLIKELY(exponent > 9999))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user