From 11076bf337a6b2e92ef138cb5ba4ce4694c434a4 Mon Sep 17 00:00:00 2001 From: John Keiser Date: Tue, 4 Aug 2020 13:52:35 -0700 Subject: [PATCH] containing_scope -> open_container --- src/generic/dom_parser_implementation.h | 10 ++++++---- src/generic/stage2/allocate.h | 4 ++-- src/generic/stage2/tape_builder.h | 10 +++++----- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/generic/dom_parser_implementation.h b/src/generic/dom_parser_implementation.h index 2dca1cae..28b6d2b9 100644 --- a/src/generic/dom_parser_implementation.h +++ b/src/generic/dom_parser_implementation.h @@ -4,16 +4,18 @@ namespace { namespace SIMDJSON_IMPLEMENTATION { -// expectation: sizeof(scope_descriptor) = 64/8. -struct scope_descriptor { +// expectation: sizeof(open_container) = 64/8. +struct open_container { uint32_t tape_index; // where, on the tape, does the scope ([,{) begins uint32_t count; // how many elements in the scope -}; // struct scope_descriptor +}; // struct open_container + +static_assert(sizeof(open_container) == 64/8, "Open container must be 64 bits"); class dom_parser_implementation final : public internal::dom_parser_implementation { public: /** Tape location of each open { or [ */ - std::unique_ptr containing_scope{}; + std::unique_ptr open_containers{}; /** Whether each open container is a [ or { */ std::unique_ptr is_array{}; /** Buffer passed to stage 1 */ diff --git a/src/generic/stage2/allocate.h b/src/generic/stage2/allocate.h index cc13148d..34b35f27 100644 --- a/src/generic/stage2/allocate.h +++ b/src/generic/stage2/allocate.h @@ -7,10 +7,10 @@ namespace allocate { // Allocates stage 2 internal state and outputs in the parser // simdjson_really_inline error_code set_max_depth(dom_parser_implementation &parser, size_t max_depth) { - parser.containing_scope.reset(new (std::nothrow) scope_descriptor[max_depth]); + parser.open_containers.reset(new (std::nothrow) open_container[max_depth]); parser.is_array.reset(new (std::nothrow) bool[max_depth]); - if (!parser.is_array || !parser.containing_scope) { + if (!parser.is_array || !parser.open_containers) { return MEMALLOC; } return SUCCESS; diff --git a/src/generic/stage2/tape_builder.h b/src/generic/stage2/tape_builder.h index a5f210b4..d57bc21d 100644 --- a/src/generic/stage2/tape_builder.h +++ b/src/generic/stage2/tape_builder.h @@ -173,7 +173,7 @@ private: // increment_count increments the count of keys in an object or values in an array. simdjson_really_inline void increment_count(structural_parser &parser) { - parser.dom_parser.containing_scope[parser.depth].count++; // we have a key value pair in the object at parser.dom_parser.depth - 1 + parser.dom_parser.open_containers[parser.depth].count++; // we have a key value pair in the object at parser.dom_parser.depth - 1 } // private: @@ -189,19 +189,19 @@ private: } simdjson_really_inline void start_container(structural_parser &parser) { - parser.dom_parser.containing_scope[parser.depth].tape_index = next_tape_index(parser); - parser.dom_parser.containing_scope[parser.depth].count = 0; + parser.dom_parser.open_containers[parser.depth].tape_index = next_tape_index(parser); + parser.dom_parser.open_containers[parser.depth].count = 0; tape.skip(); // We don't actually *write* the start element until the end. } simdjson_really_inline void end_container(structural_parser &parser, internal::tape_type start, internal::tape_type end) noexcept { // Write the ending tape element, pointing at the start location - const uint32_t start_tape_index = parser.dom_parser.containing_scope[parser.depth].tape_index; + const uint32_t start_tape_index = parser.dom_parser.open_containers[parser.depth].tape_index; tape.append(start_tape_index, end); // Write the start tape element, pointing at the end location (and including count) // count can overflow if it exceeds 24 bits... so we saturate // the convention being that a cnt of 0xffffff or more is undetermined in value (>= 0xffffff). - const uint32_t count = parser.dom_parser.containing_scope[parser.depth].count; + const uint32_t count = parser.dom_parser.open_containers[parser.depth].count; const uint32_t cntsat = count > 0xFFFFFF ? 0xFFFFFF : count; tape_writer::write(parser.dom_parser.doc->tape[start_tape_index], next_tape_index(parser) | (uint64_t(cntsat) << 32), start); }