diff --git a/include/simdjson/document.h b/include/simdjson/document.h index 27f9902ef..4002aea63 100644 --- a/include/simdjson/document.h +++ b/include/simdjson/document.h @@ -1042,7 +1042,7 @@ public: really_inline bool on_number_u64(uint64_t value) noexcept; ///< @private really_inline bool on_number_double(double value) noexcept; ///< @private - really_inline void increment_count(uint32_t depth) noexcept; ///< @private + really_inline void increment_count(scope_descriptor &scope) noexcept; ///< @private really_inline void end_scope(uint32_t depth) noexcept; ///< @private private: /** diff --git a/src/document_parser_callbacks.h b/src/document_parser_callbacks.h index e59d6bd97..5dd5b1eed 100644 --- a/src/document_parser_callbacks.h +++ b/src/document_parser_callbacks.h @@ -30,8 +30,8 @@ really_inline error_code parser::on_success(error_code success_code) noexcept { // Note that if you are at the level of the values or elements, the count // must be increment in the preceding depth (depth-1) where the array or // the object resides. -really_inline void parser::increment_count(uint32_t depth) noexcept { - containing_scope[depth].count++; +really_inline void parser::increment_count(scope_descriptor &scope) noexcept { + scope.count++; } really_inline bool parser::on_start_document(uint32_t depth) noexcept { diff --git a/src/generic/stage2_build_tape.h b/src/generic/stage2_build_tape.h index da714d4fe..d1a1a42ae 100644 --- a/src/generic/stage2_build_tape.h +++ b/src/generic/stage2_build_tape.h @@ -376,7 +376,7 @@ WARN_UNUSED error_code implementation::stage2(const uint8_t *buf, size_t len, pa object_begin: switch (parser.advance_char()) { case '"': { - doc_parser.increment_count(parser.depth - 1); // we have a key value pair in the object at parser.depth - 1 + doc_parser.increment_count(doc_parser.containing_scope[parser.depth - 1]); // we have a key value pair in the object at parser.depth - 1 FAIL_IF( parser.parse_string() ); goto object_key_state; } @@ -395,7 +395,7 @@ object_key_state: object_continue: switch (parser.advance_char()) { case ',': - doc_parser.increment_count(parser.depth - 1); // we have a key value pair in the object at parser.depth - 1 + doc_parser.increment_count(doc_parser.containing_scope[parser.depth - 1]); // we have a key value pair in the object at parser.depth - 1 FAIL_IF( parser.advance_char() != '"' ); FAIL_IF( parser.parse_string() ); goto object_key_state; @@ -417,7 +417,7 @@ array_begin: parser.end_array(); goto scope_end; } - doc_parser.increment_count(parser.depth - 1); // we have a new value in the array at parser.depth - 1 + doc_parser.increment_count(doc_parser.containing_scope[parser.depth - 1]); // we have a new value in the array at parser.depth - 1 main_array_switch: /* we call update char on all paths in, so we can peek at parser.c on the @@ -427,7 +427,7 @@ main_array_switch: array_continue: switch (parser.advance_char()) { case ',': - doc_parser.increment_count(parser.depth - 1); // we have a new value in the array at parser.depth - 1 + doc_parser.increment_count(doc_parser.containing_scope[parser.depth - 1]); // we have a new value in the array at parser.depth - 1 parser.advance_char(); goto main_array_switch; case ']': diff --git a/src/generic/stage2_streaming_build_tape.h b/src/generic/stage2_streaming_build_tape.h index f1b8576c3..de6df286f 100755 --- a/src/generic/stage2_streaming_build_tape.h +++ b/src/generic/stage2_streaming_build_tape.h @@ -97,7 +97,7 @@ object_begin: object_key_parser: FAIL_IF( parser.advance_char() != ':' ); - doc_parser.increment_count(parser.depth - 1); // we have a key value pair in the object at parser.depth - 1 + doc_parser.increment_count(doc_parser.containing_scope[parser.depth - 1]); // we have a key value pair in the object at parser.depth - 1 parser.advance_char(); GOTO( parser.parse_value(addresses, addresses.object_continue) ); @@ -125,7 +125,7 @@ array_begin: parser.end_array(); goto scope_end; } - doc_parser.increment_count(parser.depth - 1); // we have a new value in the array at parser.depth - 1 + doc_parser.increment_count(doc_parser.containing_scope[parser.depth - 1]); // we have a new value in the array at parser.depth - 1 main_array_switch: /* we call update char on all paths in, so we can peek at parser.c on the @@ -135,7 +135,7 @@ main_array_switch: array_continue: switch (parser.advance_char()) { case ',': - doc_parser.increment_count(parser.depth - 1); // we have a new value in the array at parser.depth - 1 + doc_parser.increment_count(doc_parser.containing_scope[parser.depth - 1]); // we have a new value in the array at parser.depth - 1 parser.advance_char(); goto main_array_switch; case ']':