Skip to content

Commit fa81068

Browse files
committed
Simplify structural_parser.start()
1 parent 70c2a1c commit fa81068

File tree

2 files changed

+12
-24
lines changed

2 files changed

+12
-24
lines changed

src/generic/stage2/structural_iterator.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,8 @@ class structural_iterator {
3434
return parser.len - *current_structural;
3535
}
3636

37-
really_inline bool past_end(uint32_t n_structural_indexes) {
38-
return current_structural >= &parser.structural_indexes[n_structural_indexes];
39-
}
40-
really_inline bool at_end(uint32_t n_structural_indexes) {
41-
return current_structural == &parser.structural_indexes[n_structural_indexes];
37+
really_inline bool at_end() {
38+
return current_structural == &parser.structural_indexes[parser.n_structural_indexes];
4239
}
4340
really_inline bool at_beginning() {
4441
return current_structural == parser.structural_indexes.get();

src/generic/stage2/structural_parser.h

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,16 @@ struct structural_parser : structural_iterator {
223223
return SUCCESS;
224224
}
225225

226+
WARN_UNUSED really_inline error_code start() {
227+
logger::log_start();
228+
229+
// If there are no structurals left, return EMPTY
230+
if (at_end()) { return EMPTY; }
231+
232+
// Push the root scope (there is always at least one scope)
233+
return start_document();
234+
}
235+
226236
WARN_UNUSED really_inline error_code finish() {
227237
end_document();
228238
parser.next_structural_index = uint32_t(current_structural + 1 - &parser.structural_indexes[0]);
@@ -235,29 +245,10 @@ struct structural_parser : structural_iterator {
235245
return SUCCESS;
236246
}
237247

238-
really_inline void init() {
239-
log_start();
240-
}
241-
242-
WARN_UNUSED really_inline error_code start() {
243-
// If there are no structurals left, return EMPTY
244-
if (at_end(parser.n_structural_indexes)) {
245-
return EMPTY;
246-
}
247-
248-
init();
249-
// Push the root scope (there is always at least one scope)
250-
return start_document();
251-
}
252-
253248
really_inline void log_value(const char *type) {
254249
logger::log_line(*this, "", type, "");
255250
}
256251

257-
static really_inline void log_start() {
258-
logger::log_start();
259-
}
260-
261252
really_inline void log_start_value(const char *type) {
262253
logger::log_line(*this, "+", type, "");
263254
if (logger::LOG_ENABLED) { logger::log_depth++; }

0 commit comments

Comments
 (0)