mirror of
https://github.com/nlohmann/json.git
synced 2026-10-22 22:08:55 +00:00
Fix the clang-tidy findings in the diff and JSON pointer code
- diff_target_values holds its inline values in a std::array (a type with an empty user-provided constructor, as the serializer's buffers, so that -Weffc++ is met and they stay uninitialized) and declares its move members as deleted - auto for an iterator and a cast, and parentheses around a % json::diff() instructions are unchanged within noise (Apple clang, twitter and citm_catalog). Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
3 files changed
+38
-12
No files matched your search
@@ -19,6 +19,7 @@
|
||||
#define INCLUDE_NLOHMANN_JSON_HPP_
|
||||
|
||||
#include <algorithm> // all_of, find, for_each, none_of
|
||||
#include <array> // array
|
||||
#include <cmath> // isnan
|
||||
#include <cstddef> // nullptr_t, ptrdiff_t, size_t
|
||||
#include <cstdint> // uint8_t
|
||||
@@ -7447,7 +7448,7 @@ public:
|
||||
// added without looking them up
|
||||
basic_json entry(value_t::object);
|
||||
auto& members = *entry.m_data.m_value.object;
|
||||
typename object_t::iterator hint = members.end();
|
||||
auto hint = members.end();
|
||||
json_pointer::add_flattened(members, hint, string_t("op"), string_t(op), detail::priority_tag<2> {});
|
||||
json_pointer::add_flattened(members, hint, string_t("path"), path, detail::priority_tag<2> {});
|
||||
if (value != nullptr)
|
||||
@@ -7483,9 +7484,13 @@ public:
|
||||
class diff_target_values
|
||||
{
|
||||
public:
|
||||
diff_target_values() = default;
|
||||
diff_target_values() noexcept
|
||||
: inline_items() // NOLINT(readability-redundant-member-init)
|
||||
{}
|
||||
diff_target_values(const diff_target_values&) = delete;
|
||||
diff_target_values& operator=(const diff_target_values&) = delete;
|
||||
diff_target_values(diff_target_values&&) = delete;
|
||||
diff_target_values& operator=(diff_target_values&&) = delete;
|
||||
~diff_target_values() = default;
|
||||
|
||||
void reserve(const std::size_t n)
|
||||
@@ -7514,10 +7519,18 @@ public:
|
||||
|
||||
private:
|
||||
static constexpr std::size_t inline_size = 16;
|
||||
/// the values of a small object, left uninitialized: they are written
|
||||
/// before they are read (the user-provided constructor keeps the
|
||||
/// member initialization, which -Weffc++ asks for, from zeroing them)
|
||||
struct uninitialized_items : std::array<const basic_json*, inline_size>
|
||||
{
|
||||
uninitialized_items() noexcept {} // NOLINT(modernize-use-equals-default,hicpp-use-equals-default,cppcoreguidelines-pro-type-member-init,hicpp-member-init): see above
|
||||
};
|
||||
|
||||
std::size_t count = 0;
|
||||
const basic_json** items = inline_items;
|
||||
std::vector<const basic_json*> large{}; // NOLINT(readability-redundant-member-init)
|
||||
const basic_json* inline_items[inline_size]; // NOLINT(cppcoreguidelines-pro-type-member-init,hicpp-member-init)
|
||||
uninitialized_items inline_items;
|
||||
const basic_json** items = inline_items.data();
|
||||
};
|
||||
|
||||
/// @brief append "/" and the decimal representation of @a index to @a path
|
||||
|
||||
Reference in new issue
Block a user