Give is_array responsibility to json_iterator

This commit is contained in:
John Keiser 2020-08-12 09:40:52 -07:00
parent bdfa8aca28
commit 24f5936cbf
2 changed files with 2 additions and 7 deletions

View File

@ -78,6 +78,7 @@ object_begin:
depth++;
if (depth >= dom_parser.max_depth()) { log_error("Exceeded max depth!"); return DEPTH_ERROR; }
SIMDJSON_TRY( visitor.visit_object_start(*this) );
dom_parser.is_array[depth] = false;
{
auto key = advance();
@ -124,6 +125,7 @@ array_begin:
depth++;
if (depth >= dom_parser.max_depth()) { log_error("Exceeded max depth!"); return DEPTH_ERROR; }
SIMDJSON_TRY( visitor.visit_array_start(*this) );
dom_parser.is_array[depth] = true;
SIMDJSON_TRY( visitor.increment_count(*this) );
array_value:

View File

@ -28,7 +28,6 @@ struct tape_builder {
// increment_count increments the count of keys in an object or values in an array.
SIMDJSON_WARN_UNUSED simdjson_really_inline error_code increment_count(json_iterator &iter) noexcept;
simdjson_really_inline bool in_array(json_iterator &iter) noexcept;
private:
/** Next location to write to tape */
@ -108,19 +107,16 @@ SIMDJSON_WARN_UNUSED simdjson_really_inline error_code tape_builder::visit_empty
SIMDJSON_WARN_UNUSED simdjson_really_inline error_code tape_builder::visit_document_start(json_iterator &iter) noexcept {
iter.log_start_value("document");
start_container(iter);
iter.dom_parser.is_array[iter.depth] = false;
return SUCCESS;
}
SIMDJSON_WARN_UNUSED simdjson_really_inline error_code tape_builder::visit_object_start(json_iterator &iter) noexcept {
iter.log_start_value("object");
start_container(iter);
iter.dom_parser.is_array[iter.depth] = false;
return SUCCESS;
}
SIMDJSON_WARN_UNUSED simdjson_really_inline error_code tape_builder::visit_array_start(json_iterator &iter) noexcept {
iter.log_start_value("array");
start_container(iter);
iter.dom_parser.is_array[iter.depth] = true;
return SUCCESS;
}
@ -147,9 +143,6 @@ SIMDJSON_WARN_UNUSED simdjson_really_inline error_code tape_builder::increment_c
iter.dom_parser.open_containers[iter.depth].count++; // we have a key value pair in the object at parser.dom_parser.depth - 1
return SUCCESS;
}
simdjson_really_inline bool tape_builder::in_array(json_iterator &iter) noexcept {
return iter.dom_parser.is_array[iter.depth];
}
simdjson_really_inline tape_builder::tape_builder(dom::document &doc) noexcept : tape{doc.tape.get()}, current_string_buf_loc{doc.string_buf.get()} {}