Only set container depth when a container iteration starts
This commit is contained in:
parent
22742b6bd6
commit
9d693da852
|
@ -25,10 +25,6 @@ simdjson_really_inline json_iterator::json_iterator(const uint8_t *buf, ondemand
|
|||
_string_buf_loc{parser->string_buf.get()},
|
||||
_depth{1}
|
||||
{
|
||||
#if SIMDJSON_API_USAGE_CHECKS
|
||||
parser->start_positions[0] = token.index;
|
||||
parser->start_positions[1] = token.index;
|
||||
#endif
|
||||
logger::log_headers();
|
||||
}
|
||||
|
||||
|
@ -159,9 +155,6 @@ simdjson_really_inline void json_iterator::descend_to(depth_t child_depth) noexc
|
|||
SIMDJSON_ASSUME(child_depth >= 1 && child_depth < INT32_MAX);
|
||||
SIMDJSON_ASSUME(_depth == child_depth - 1);
|
||||
_depth = child_depth;
|
||||
#if SIMDJSON_API_USAGE_CHECKS
|
||||
parser->start_positions[_depth] = token.index;
|
||||
#endif
|
||||
}
|
||||
|
||||
simdjson_really_inline depth_t json_iterator::depth() const noexcept {
|
||||
|
@ -196,6 +189,10 @@ simdjson_really_inline void json_iterator::reenter_child(token_position position
|
|||
simdjson_really_inline token_position json_iterator::start_position(depth_t depth) const noexcept {
|
||||
return parser->start_positions[depth];
|
||||
}
|
||||
simdjson_really_inline void json_iterator::set_start_position(depth_t depth, token_position position) noexcept {
|
||||
parser->start_positions[depth] = position;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -183,6 +183,7 @@ public:
|
|||
simdjson_really_inline void reenter_child(token_position position, depth_t child_depth) noexcept;
|
||||
#if SIMDJSON_API_USAGE_CHECKS
|
||||
simdjson_really_inline token_position start_position(depth_t depth) const noexcept;
|
||||
simdjson_really_inline void set_start_position(depth_t depth, token_position position) noexcept;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
|
|
@ -25,6 +25,9 @@ simdjson_warn_unused simdjson_really_inline bool value_iterator::started_object(
|
|||
return false;
|
||||
}
|
||||
logger::log_start_value(*_json_iter, "object");
|
||||
#if SIMDJSON_API_USAGE_CHECKS
|
||||
_json_iter->set_start_position(_depth, _start_position);
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -285,6 +288,9 @@ simdjson_warn_unused simdjson_really_inline bool value_iterator::started_array()
|
|||
}
|
||||
logger::log_start_value(*_json_iter, "array");
|
||||
_json_iter->descend_to(depth()+1);
|
||||
#if SIMDJSON_API_USAGE_CHECKS
|
||||
_json_iter->set_start_position(_depth, _start_position);
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue