Skip to content

Commit 4806238

Browse files
committed
Move parser to structural_iterator
1 parent 3636aa5 commit 4806238

2 files changed

Lines changed: 16 additions & 16 deletions

File tree

src/generic/stage2/structural_iterator.h

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,21 @@ namespace stage2 {
22

33
class structural_iterator {
44
public:
5-
really_inline structural_iterator(const uint8_t* _buf, size_t _len, const uint32_t *_structural_indexes, size_t next_structural_index)
6-
: buf{_buf},
7-
len{_len},
8-
structural_indexes{_structural_indexes},
9-
next_structural{next_structural_index}
10-
{}
5+
const uint8_t* const buf;
6+
const size_t len;
7+
const uint32_t* const structural_indexes;
8+
size_t next_structural; // next structural index
9+
size_t idx{0}; // location of the structural character in the input (buf)
10+
uint8_t c{0}; // used to track the (structural) character we are looking at
11+
dom_parser_implementation &parser;
12+
13+
really_inline structural_iterator(dom_parser_implementation &_parser, size_t _next_structural)
14+
: buf{_parser.buf},
15+
len{_parser.len},
16+
structural_indexes{_parser.structural_indexes.get()},
17+
next_structural{_next_structural},
18+
parser{_parser} {
19+
}
1120
really_inline char advance_char() {
1221
idx = structural_indexes[next_structural];
1322
next_structural++;
@@ -63,13 +72,6 @@ class structural_iterator {
6372
really_inline size_t next_structural_index() {
6473
return next_structural;
6574
}
66-
67-
const uint8_t* const buf;
68-
const size_t len;
69-
const uint32_t* const structural_indexes;
70-
size_t next_structural; // next structural index
71-
size_t idx{0}; // location of the structural character in the input (buf)
72-
uint8_t c{0}; // used to track the (structural) character we are looking at
7375
};
7476

7577
} // namespace stage2

src/generic/stage2/structural_parser.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,13 @@ struct number_writer {
7070
}; // struct number_writer
7171

7272
struct structural_parser : structural_iterator {
73-
dom_parser_implementation &parser;
7473
/** Next write location in the string buf for stage 2 parsing */
7574
uint8_t *current_string_buf_loc{};
7675
uint32_t depth;
7776

7877
// For non-streaming, to pass an explicit 0 as next_structural, which enables optimizations
7978
really_inline structural_parser(dom_parser_implementation &_parser, uint32_t _next_structural)
80-
: structural_iterator(_parser.buf, _parser.len, _parser.structural_indexes.get(), _next_structural),
81-
parser{_parser},
79+
: structural_iterator(_parser, _next_structural),
8280
depth{0} {
8381
}
8482

0 commit comments

Comments
 (0)