diff --git a/src/generic/stage2/structural_iterator.h b/src/generic/stage2/structural_iterator.h index 92a990b21..50ee3edec 100644 --- a/src/generic/stage2/structural_iterator.h +++ b/src/generic/stage2/structural_iterator.h @@ -2,12 +2,21 @@ namespace stage2 { class structural_iterator { public: - really_inline structural_iterator(const uint8_t* _buf, size_t _len, const uint32_t *_structural_indexes, size_t next_structural_index) - : buf{_buf}, - len{_len}, - structural_indexes{_structural_indexes}, - next_structural{next_structural_index} - {} + const uint8_t* const buf; + const size_t len; + const uint32_t* const structural_indexes; + size_t next_structural; // next structural index + size_t idx{0}; // location of the structural character in the input (buf) + uint8_t c{0}; // used to track the (structural) character we are looking at + dom_parser_implementation &parser; + + really_inline structural_iterator(dom_parser_implementation &_parser, size_t _next_structural) + : buf{_parser.buf}, + len{_parser.len}, + structural_indexes{_parser.structural_indexes.get()}, + next_structural{_next_structural}, + parser{_parser} { + } really_inline char advance_char() { idx = structural_indexes[next_structural]; next_structural++; @@ -63,13 +72,6 @@ public: really_inline size_t next_structural_index() { return next_structural; } - - const uint8_t* const buf; - const size_t len; - const uint32_t* const structural_indexes; - size_t next_structural; // next structural index - size_t idx{0}; // location of the structural character in the input (buf) - uint8_t c{0}; // used to track the (structural) character we are looking at }; } // namespace stage2 diff --git a/src/generic/stage2/structural_parser.h b/src/generic/stage2/structural_parser.h index 853f18afa..0e3ea6353 100644 --- a/src/generic/stage2/structural_parser.h +++ b/src/generic/stage2/structural_parser.h @@ -70,15 +70,13 @@ struct number_writer { }; // struct number_writer struct structural_parser : structural_iterator { - dom_parser_implementation &parser; /** Next write location in the string buf for stage 2 parsing */ uint8_t *current_string_buf_loc{}; uint32_t depth; // For non-streaming, to pass an explicit 0 as next_structural, which enables optimizations really_inline structural_parser(dom_parser_implementation &_parser, uint32_t _next_structural) - : structural_iterator(_parser.buf, _parser.len, _parser.structural_indexes.get(), _next_structural), - parser{_parser}, + : structural_iterator(_parser, _next_structural), depth{0} { }