diff --git a/include/nlohmann/detail/view/image.hpp b/include/nlohmann/detail/view/image.hpp index a1cd95bc6..bb52e527e 100644 --- a/include/nlohmann/detail/view/image.hpp +++ b/include/nlohmann/detail/view/image.hpp @@ -105,7 +105,7 @@ inline void compact_nodes(const document_data& d, std::size_t arena_size, std::v } return r; }; - const auto emit = [&](const node * v) + const auto copy_node = [&](const node * v) { node r = *v; switch (static_cast(v->kind)) @@ -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.nodes); + copy_node(d.nodes); while (!stack.empty()) { frame& top = stack.back(); @@ -184,7 +184,7 @@ inline void compact_nodes(const document_data& d, std::size_t arena_size, std::v v = document_data::deref(top.cur); top.cur = document_data::after(top.cur); } - emit(v); // may grow the stack (top is not used afterwards) + copy_node(v); // may grow the stack (top is not used afterwards) } } diff --git a/single_include/nlohmann/json_view.hpp b/single_include/nlohmann/json_view.hpp index a6b42fd61..e9b43f342 100644 --- a/single_include/nlohmann/json_view.hpp +++ b/single_include/nlohmann/json_view.hpp @@ -4623,7 +4623,7 @@ inline void compact_nodes(const document_data& d, std::size_t arena_size, std::v } return r; }; - const auto emit = [&](const node * v) + const auto copy_node = [&](const node * v) { node r = *v; switch (static_cast(v->kind)) @@ -4677,7 +4677,7 @@ inline void compact_nodes(const document_data& d, std::size_t arena_size, std::v } out.push_back(r); }; - emit(d.nodes); + copy_node(d.nodes); while (!stack.empty()) { frame& top = stack.back(); @@ -4702,7 +4702,7 @@ inline void compact_nodes(const document_data& d, std::size_t arena_size, std::v v = document_data::deref(top.cur); top.cur = document_data::after(top.cur); } - emit(v); // may grow the stack (top is not used afterwards) + copy_node(v); // may grow the stack (top is not used afterwards) } } diff --git a/tests/src/unit-json_view_image.cpp b/tests/src/unit-json_view_image.cpp index be96d7168..994bd211c 100644 --- a/tests/src/unit-json_view_image.cpp +++ b/tests/src/unit-json_view_image.cpp @@ -294,7 +294,7 @@ TEST_CASE("json_view images: round trips") { // the hash is not seeded: keys can be found that land in one slot of // a table (see json_view: "colliding keys") - const auto keys_for = [](std::size_t slots, std::size_t colliding_count, std::size_t spread_count) + const auto keys_for = [](std::size_t table_size, std::size_t colliding_count, std::size_t spread_count) { std::vector colliding; std::vector spread; @@ -306,7 +306,7 @@ TEST_CASE("json_view images: round trips") { key[i] = static_cast('a' + (x % 26)); } - const bool lands_in_slot_zero = (nlohmann::detail::view::key_hash(key.data(), key.size()) & (slots - 1)) == 0; + const bool lands_in_slot_zero = (nlohmann::detail::view::key_hash(key.data(), key.size()) & (table_size - 1)) == 0; if (lands_in_slot_zero && colliding.size() < colliding_count) { colliding.push_back(key); @@ -335,14 +335,14 @@ TEST_CASE("json_view images: round trips") // long chain const struct // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays): an unnamed type { - std::size_t slots; + std::size_t table_size; std::size_t colliding; std::size_t spread; } cases[] = {{1024, 300, 0}, {512, 40, 160}}; for (const auto& c : cases) { - CAPTURE(c.slots) - std::vector keys = keys_for(c.slots, c.colliding, c.spread); + CAPTURE(c.table_size) + std::vector keys = keys_for(c.table_size, c.colliding, c.spread); const std::size_t members = keys.size(); // a duplicate of a colliding key, of the first and of a spread key const std::vector duplicated = {keys[c.colliding - 1], keys[0], keys[members - 1]};