Skip to content

Commit c5862d6

Browse files
committed
Remove empty_object/empty_array
1 parent 57eb554 commit c5862d6

File tree

1 file changed

+6
-26
lines changed

1 file changed

+6
-26
lines changed

src/generic/stage2/json_iterator.h

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -57,26 +57,6 @@ class json_iterator {
5757
logger::log_line(*this, "", "ERROR", error);
5858
}
5959

60-
private:
61-
template<typename T>
62-
SIMDJSON_WARN_UNUSED simdjson_really_inline bool empty_object(T &visitor) {
63-
if (peek_next_char() == '}') {
64-
advance();
65-
visitor.empty_object(*this);
66-
return true;
67-
}
68-
return false;
69-
}
70-
template<typename T>
71-
SIMDJSON_WARN_UNUSED simdjson_really_inline bool empty_array(T &visitor) {
72-
if (peek_next_char() == ']') {
73-
advance();
74-
visitor.empty_array(*this);
75-
return true;
76-
}
77-
return false;
78-
}
79-
8060
simdjson_really_inline uint8_t last_structural() {
8161
return buf[dom_parser.structural_indexes[dom_parser.n_structural_indexes - 1]];
8262
}
@@ -116,8 +96,8 @@ SIMDJSON_WARN_UNUSED simdjson_really_inline error_code json_iterator::walk_docum
11696
}
11797

11898
switch (*value) {
119-
case '{': if (!empty_object(visitor)) { goto object_begin; }; break;
120-
case '[': if (!empty_array(visitor)) { goto array_begin; }; break;
99+
case '{': if (peek_next_char() == '}') { advance(); visitor.empty_object(*this); break; } goto object_begin;
100+
case '[': if (peek_next_char() == ']') { advance(); visitor.empty_array(*this); break; } goto array_begin;
121101
default: SIMDJSON_TRY( visitor.root_primitive(*this, value) ); break;
122102
}
123103
}
@@ -143,8 +123,8 @@ SIMDJSON_WARN_UNUSED simdjson_really_inline error_code json_iterator::walk_docum
143123
{
144124
auto value = advance();
145125
switch (*value) {
146-
case '{': if (!empty_object(visitor)) { goto object_begin; }; break;
147-
case '[': if (!empty_array(visitor)) { goto array_begin; }; break;
126+
case '{': if (peek_next_char() == '}') { advance(); visitor.empty_object(*this); break; } goto object_begin;
127+
case '[': if (peek_next_char() == ']') { advance(); visitor.empty_array(*this); break; } goto array_begin;
148128
default: SIMDJSON_TRY( visitor.primitive(*this, value) ); break;
149129
}
150130
}
@@ -182,8 +162,8 @@ SIMDJSON_WARN_UNUSED simdjson_really_inline error_code json_iterator::walk_docum
182162
{
183163
auto value = advance();
184164
switch (*value) {
185-
case '{': if (!empty_object(visitor)) { goto object_begin; }; break;
186-
case '[': if (!empty_array(visitor)) { goto array_begin; }; break;
165+
case '{': if (peek_next_char() == '}') { advance(); visitor.empty_object(*this); break; } goto object_begin;
166+
case '[': if (peek_next_char() == ']') { advance(); visitor.empty_array(*this); break; } goto array_begin;
187167
default: SIMDJSON_TRY( visitor.primitive(*this, value) ); break;
188168
}
189169
}

0 commit comments

Comments
 (0)