Skip to content

Commit 07fe7ad

Browse files
committed
Use the same increment_count() everywhere
1 parent 16d88cc commit 07fe7ad

2 files changed

Lines changed: 11 additions & 7 deletions

File tree

src/generic/stage2_build_tape.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,10 @@ struct structural_parser {
162162
return false;
163163
}
164164

165+
really_inline void increment_count() {
166+
doc_parser.increment_count(doc_parser.containing_scope[depth - 1]); // we have a key value pair in the object at parser.depth - 1
167+
}
168+
165169
WARN_UNUSED really_inline bool parse_string() {
166170
uint8_t *dst = doc_parser.on_start_string();
167171
dst = stringparsing::parse_string(structurals.current(), dst);
@@ -376,7 +380,7 @@ WARN_UNUSED error_code implementation::stage2(const uint8_t *buf, size_t len, pa
376380
object_begin:
377381
switch (parser.advance_char()) {
378382
case '"': {
379-
doc_parser.increment_count(doc_parser.containing_scope[parser.depth - 1]); // we have a key value pair in the object at parser.depth - 1
383+
parser.increment_count();
380384
FAIL_IF( parser.parse_string() );
381385
goto object_key_state;
382386
}
@@ -395,7 +399,7 @@ WARN_UNUSED error_code implementation::stage2(const uint8_t *buf, size_t len, pa
395399
object_continue:
396400
switch (parser.advance_char()) {
397401
case ',':
398-
doc_parser.increment_count(doc_parser.containing_scope[parser.depth - 1]); // we have a key value pair in the object at parser.depth - 1
402+
parser.increment_count();
399403
FAIL_IF( parser.advance_char() != '"' );
400404
FAIL_IF( parser.parse_string() );
401405
goto object_key_state;
@@ -417,7 +421,7 @@ WARN_UNUSED error_code implementation::stage2(const uint8_t *buf, size_t len, pa
417421
parser.end_array();
418422
goto scope_end;
419423
}
420-
doc_parser.increment_count(doc_parser.containing_scope[parser.depth - 1]); // we have a new value in the array at parser.depth - 1
424+
parser.increment_count();
421425

422426
main_array_switch:
423427
/* we call update char on all paths in, so we can peek at parser.c on the
@@ -427,7 +431,7 @@ WARN_UNUSED error_code implementation::stage2(const uint8_t *buf, size_t len, pa
427431
array_continue:
428432
switch (parser.advance_char()) {
429433
case ',':
430-
doc_parser.increment_count(doc_parser.containing_scope[parser.depth - 1]); // we have a new value in the array at parser.depth - 1
434+
parser.increment_count();
431435
parser.advance_char();
432436
goto main_array_switch;
433437
case ']':

src/generic/stage2_streaming_build_tape.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ WARN_UNUSED error_code implementation::stage2(const uint8_t *buf, size_t len, pa
9797

9898
object_key_parser:
9999
FAIL_IF( parser.advance_char() != ':' );
100-
doc_parser.increment_count(doc_parser.containing_scope[parser.depth - 1]); // we have a key value pair in the object at parser.depth - 1
100+
parser.increment_count();
101101
parser.advance_char();
102102
GOTO( parser.parse_value(addresses, addresses.object_continue) );
103103

@@ -125,7 +125,7 @@ WARN_UNUSED error_code implementation::stage2(const uint8_t *buf, size_t len, pa
125125
parser.end_array();
126126
goto scope_end;
127127
}
128-
doc_parser.increment_count(doc_parser.containing_scope[parser.depth - 1]); // we have a new value in the array at parser.depth - 1
128+
parser.increment_count();
129129

130130
main_array_switch:
131131
/* we call update char on all paths in, so we can peek at parser.c on the
@@ -135,7 +135,7 @@ WARN_UNUSED error_code implementation::stage2(const uint8_t *buf, size_t len, pa
135135
array_continue:
136136
switch (parser.advance_char()) {
137137
case ',':
138-
doc_parser.increment_count(doc_parser.containing_scope[parser.depth - 1]); // we have a new value in the array at parser.depth - 1
138+
parser.increment_count();
139139
parser.advance_char();
140140
goto main_array_switch;
141141
case ']':

0 commit comments

Comments
 (0)