From 81c13d409e7dc3cc1ba1c10795e4ae1d211264d2 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Fri, 16 Oct 2026 08:32:08 +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/edit.hpp | 2 +- include/nlohmann/detail/view/edit_storage.hpp | 6 +++--- single_include/nlohmann/json_view.hpp | 8 ++++---- tests/src/unit-json_view_builder.cpp | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/nlohmann/detail/view/edit.hpp b/include/nlohmann/detail/view/edit.hpp index fb8d769f3..57a3297b3 100644 --- a/include/nlohmann/detail/view/edit.hpp +++ b/include/nlohmann/detail/view/edit.hpp @@ -363,7 +363,7 @@ class editor const std::uint8_t linked = slot->flags & node_flags::linked; if (e.region == nullptr) { - if (is_container(*slot) && slot->next > 1 && slot != m_doc.tape && linked == 0) + if (is_container(*slot) && slot->next > 1 && slot != m_doc.nodes && linked == 0) { // The slot spans its old elements in the enclosing sequence, but // a scalar is one node: the enclosing container first switches to diff --git a/include/nlohmann/detail/view/edit_storage.hpp b/include/nlohmann/detail/view/edit_storage.hpp index de6f3e577..a4de44112 100644 --- a/include/nlohmann/detail/view/edit_storage.hpp +++ b/include/nlohmann/detail/view/edit_storage.hpp @@ -202,9 +202,9 @@ inline node* block_of(document_data& d, node* n, std::size_t extra) inline node* find_parent(const document_data& d, const node* target) { const std::less lt{}; - const node* lo = d.tape; - const node* hi = d.tape + d.tape_size; - const node* c = d.tape; + const node* lo = d.nodes; + const node* hi = d.nodes + d.node_count; + const node* c = d.nodes; if (lt(target, lo) || !lt(target, hi)) { if (!d.edits) diff --git a/single_include/nlohmann/json_view.hpp b/single_include/nlohmann/json_view.hpp index 73a83eb08..8026bd799 100644 --- a/single_include/nlohmann/json_view.hpp +++ b/single_include/nlohmann/json_view.hpp @@ -3010,9 +3010,9 @@ inline node* block_of(document_data& d, node* n, std::size_t extra) inline node* find_parent(const document_data& d, const node* target) { const std::less lt{}; - const node* lo = d.tape; - const node* hi = d.tape + d.tape_size; - const node* c = d.tape; + const node* lo = d.nodes; + const node* hi = d.nodes + d.node_count; + const node* c = d.nodes; if (lt(target, lo) || !lt(target, hi)) { if (!d.edits) @@ -3760,7 +3760,7 @@ class editor const std::uint8_t linked = slot->flags & node_flags::linked; if (e.region == nullptr) { - if (is_container(*slot) && slot->next > 1 && slot != m_doc.tape && linked == 0) + if (is_container(*slot) && slot->next > 1 && slot != m_doc.nodes && linked == 0) { // The slot spans its old elements in the enclosing sequence, but // a scalar is one node: the enclosing container first switches to diff --git a/tests/src/unit-json_view_builder.cpp b/tests/src/unit-json_view_builder.cpp index 9113ea383..d0c8f4b30 100644 --- a/tests/src/unit-json_view_builder.cpp +++ b/tests/src/unit-json_view_builder.cpp @@ -376,7 +376,7 @@ TEST_CASE("json_view builder") const built shallow = build(nested, false, false, false); REQUIRE(shallow.ok); shallow.data->max_depth = 1; - CHECK(nlohmann::detail::view::materialize(*shallow.data, shallow.data->nodes) == json::parse(nested)); + CHECK(nlohmann::detail::view::materialize(*shallow.data, shallow.data->nodes) == json::parse(nested)); // the open containers beyond 64 levels live on the heap for (const std::size_t depth :