Skip to content

Commit 24f5936

Browse files
committed
Give is_array responsibility to json_iterator
1 parent bdfa8ac commit 24f5936

File tree

2 files changed

+2
-7
lines changed

2 files changed

+2
-7
lines changed

src/generic/stage2/json_iterator.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ SIMDJSON_WARN_UNUSED simdjson_really_inline error_code json_iterator::walk_docum
7878
depth++;
7979
if (depth >= dom_parser.max_depth()) { log_error("Exceeded max depth!"); return DEPTH_ERROR; }
8080
SIMDJSON_TRY( visitor.visit_object_start(*this) );
81+
dom_parser.is_array[depth] = false;
8182

8283
{
8384
auto key = advance();
@@ -124,6 +125,7 @@ SIMDJSON_WARN_UNUSED simdjson_really_inline error_code json_iterator::walk_docum
124125
depth++;
125126
if (depth >= dom_parser.max_depth()) { log_error("Exceeded max depth!"); return DEPTH_ERROR; }
126127
SIMDJSON_TRY( visitor.visit_array_start(*this) );
128+
dom_parser.is_array[depth] = true;
127129
SIMDJSON_TRY( visitor.increment_count(*this) );
128130

129131
array_value:

src/generic/stage2/tape_builder.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ struct tape_builder {
2828

2929
// increment_count increments the count of keys in an object or values in an array.
3030
SIMDJSON_WARN_UNUSED simdjson_really_inline error_code increment_count(json_iterator &iter) noexcept;
31-
simdjson_really_inline bool in_array(json_iterator &iter) noexcept;
3231

3332
private:
3433
/** Next location to write to tape */
@@ -108,19 +107,16 @@ SIMDJSON_WARN_UNUSED simdjson_really_inline error_code tape_builder::visit_empty
108107
SIMDJSON_WARN_UNUSED simdjson_really_inline error_code tape_builder::visit_document_start(json_iterator &iter) noexcept {
109108
iter.log_start_value("document");
110109
start_container(iter);
111-
iter.dom_parser.is_array[iter.depth] = false;
112110
return SUCCESS;
113111
}
114112
SIMDJSON_WARN_UNUSED simdjson_really_inline error_code tape_builder::visit_object_start(json_iterator &iter) noexcept {
115113
iter.log_start_value("object");
116114
start_container(iter);
117-
iter.dom_parser.is_array[iter.depth] = false;
118115
return SUCCESS;
119116
}
120117
SIMDJSON_WARN_UNUSED simdjson_really_inline error_code tape_builder::visit_array_start(json_iterator &iter) noexcept {
121118
iter.log_start_value("array");
122119
start_container(iter);
123-
iter.dom_parser.is_array[iter.depth] = true;
124120
return SUCCESS;
125121
}
126122

@@ -147,9 +143,6 @@ SIMDJSON_WARN_UNUSED simdjson_really_inline error_code tape_builder::increment_c
147143
iter.dom_parser.open_containers[iter.depth].count++; // we have a key value pair in the object at parser.dom_parser.depth - 1
148144
return SUCCESS;
149145
}
150-
simdjson_really_inline bool tape_builder::in_array(json_iterator &iter) noexcept {
151-
return iter.dom_parser.is_array[iter.depth];
152-
}
153146

154147
simdjson_really_inline tape_builder::tape_builder(dom::document &doc) noexcept : tape{doc.tape.get()}, current_string_buf_loc{doc.string_buf.get()} {}
155148

0 commit comments

Comments
 (0)