From e5c99c8083c435fff201ef822e38558bf0621e1d Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Fri, 16 Oct 2026 08:34:39 +0200 Subject: [PATCH] Follow the renames from the review of the view builder The review of #5620 renamed document_data's tape/tape_size/tape_cap to nodes/node_count/node_capacity and made the decode arena a std::vector; adapt the code of this change to it. Signed-off-by: Niels Lohmann --- include/nlohmann/detail/view/image.hpp | 16 ++++++++-------- single_include/nlohmann/json_view.hpp | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/include/nlohmann/detail/view/image.hpp b/include/nlohmann/detail/view/image.hpp index 91ff5acc8..a1cd95bc6 100644 --- a/include/nlohmann/detail/view/image.hpp +++ b/include/nlohmann/detail/view/image.hpp @@ -159,7 +159,7 @@ inline void compact_nodes(const document_data& d, std::size_t arena_size, std::v } out.push_back(r); }; - emit(d.tape); + emit(d.nodes); while (!stack.empty()) { frame& top = stack.back(); @@ -195,8 +195,8 @@ inline std::vector save_image(const document_data& d) throw_type_error(320, "json_document images need a little-endian target"); // LCOV_EXCL_LINE #endif const std::size_t arena_size = d.arena_size; - const node* nodes = d.tape; - std::size_t count = d.tape_size; + const node* nodes = d.nodes; + std::size_t count = d.node_count; std::vector compacted; std::string text_tail; std::string arena_tail; @@ -717,10 +717,10 @@ inline void load_image(document_data& d, const std::uint8_t* image, std::size_t d.indexes.clear(); d.index_slots.clear(); d.large_objects.clear(); - d.tape_size = 0; + d.node_count = 0; d.reserve(count); - std::memcpy(d.tape, image + sizeof(h), count * sizeof(node)); - d.tape_size = count; + std::memcpy(d.nodes, image + sizeof(h), count * sizeof(node)); + d.node_count = count; const std::uint8_t* const text = image + text_at; const std::uint8_t* const arena = text + text_size + 1; d.src = reinterpret_cast(text); // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast) @@ -728,14 +728,14 @@ inline void load_image(document_data& d, const std::uint8_t* image, std::size_t d.base[0] = d.src; d.base[1] = reinterpret_cast(arena); // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast) d.arena_size = arena_size; - if (check != image_check::none && !check_image(d.tape, count, text, text_size, arena, arena_size, check == image_check::full)) + if (check != image_check::none && !check_image(d.nodes, count, text, text_size, arena, arena_size, check == image_check::full)) { throw_invalid_image("the check failed"); } // the hash indexes of large objects, as after parsing for (std::size_t i = 0; i < count; ++i) { - node& n = d.tape[i]; + node& n = d.nodes[i]; if (n.kind == static_cast(value_t::object)) { n.extra = 0; diff --git a/single_include/nlohmann/json_view.hpp b/single_include/nlohmann/json_view.hpp index 92deb9e9d..3f5d5b2fc 100644 --- a/single_include/nlohmann/json_view.hpp +++ b/single_include/nlohmann/json_view.hpp @@ -4676,7 +4676,7 @@ inline void compact_nodes(const document_data& d, std::size_t arena_size, std::v } out.push_back(r); }; - emit(d.tape); + emit(d.nodes); while (!stack.empty()) { frame& top = stack.back(); @@ -4712,8 +4712,8 @@ inline std::vector save_image(const document_data& d) throw_type_error(320, "json_document images need a little-endian target"); // LCOV_EXCL_LINE #endif const std::size_t arena_size = d.arena_size; - const node* nodes = d.tape; - std::size_t count = d.tape_size; + const node* nodes = d.nodes; + std::size_t count = d.node_count; std::vector compacted; std::string text_tail; std::string arena_tail; @@ -5234,10 +5234,10 @@ inline void load_image(document_data& d, const std::uint8_t* image, std::size_t d.indexes.clear(); d.index_slots.clear(); d.large_objects.clear(); - d.tape_size = 0; + d.node_count = 0; d.reserve(count); - std::memcpy(d.tape, image + sizeof(h), count * sizeof(node)); - d.tape_size = count; + std::memcpy(d.nodes, image + sizeof(h), count * sizeof(node)); + d.node_count = count; const std::uint8_t* const text = image + text_at; const std::uint8_t* const arena = text + text_size + 1; d.src = reinterpret_cast(text); // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast) @@ -5245,14 +5245,14 @@ inline void load_image(document_data& d, const std::uint8_t* image, std::size_t d.base[0] = d.src; d.base[1] = reinterpret_cast(arena); // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast) d.arena_size = arena_size; - if (check != image_check::none && !check_image(d.tape, count, text, text_size, arena, arena_size, check == image_check::full)) + if (check != image_check::none && !check_image(d.nodes, count, text, text_size, arena, arena_size, check == image_check::full)) { throw_invalid_image("the check failed"); } // the hash indexes of large objects, as after parsing for (std::size_t i = 0; i < count; ++i) { - node& n = d.tape[i]; + node& n = d.nodes[i]; if (n.kind == static_cast(value_t::object)) { n.extra = 0;