Skip to content

Commit 16d88cc

Browse files
committed
Don't pass depth to increment_count
1 parent 2a6e6b3 commit 16d88cc

4 files changed

Lines changed: 10 additions & 10 deletions

File tree

include/simdjson/document.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1042,7 +1042,7 @@ class parser {
10421042
really_inline bool on_number_u64(uint64_t value) noexcept; ///< @private
10431043
really_inline bool on_number_double(double value) noexcept; ///< @private
10441044

1045-
really_inline void increment_count(uint32_t depth) noexcept; ///< @private
1045+
really_inline void increment_count(scope_descriptor &scope) noexcept; ///< @private
10461046
really_inline void end_scope(uint32_t depth) noexcept; ///< @private
10471047
private:
10481048
/**

src/document_parser_callbacks.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ really_inline error_code parser::on_success(error_code success_code) noexcept {
3030
// Note that if you are at the level of the values or elements, the count
3131
// must be increment in the preceding depth (depth-1) where the array or
3232
// the object resides.
33-
really_inline void parser::increment_count(uint32_t depth) noexcept {
34-
containing_scope[depth].count++;
33+
really_inline void parser::increment_count(scope_descriptor &scope) noexcept {
34+
scope.count++;
3535
}
3636

3737
really_inline bool parser::on_start_document(uint32_t depth) noexcept {

src/generic/stage2_build_tape.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ WARN_UNUSED error_code implementation::stage2(const uint8_t *buf, size_t len, pa
376376
object_begin:
377377
switch (parser.advance_char()) {
378378
case '"': {
379-
doc_parser.increment_count(parser.depth - 1); // we have a key value pair in the object at parser.depth - 1
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
380380
FAIL_IF( parser.parse_string() );
381381
goto object_key_state;
382382
}
@@ -395,7 +395,7 @@ WARN_UNUSED error_code implementation::stage2(const uint8_t *buf, size_t len, pa
395395
object_continue:
396396
switch (parser.advance_char()) {
397397
case ',':
398-
doc_parser.increment_count(parser.depth - 1); // we have a key value pair in the object at parser.depth - 1
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
399399
FAIL_IF( parser.advance_char() != '"' );
400400
FAIL_IF( parser.parse_string() );
401401
goto object_key_state;
@@ -417,7 +417,7 @@ WARN_UNUSED error_code implementation::stage2(const uint8_t *buf, size_t len, pa
417417
parser.end_array();
418418
goto scope_end;
419419
}
420-
doc_parser.increment_count(parser.depth - 1); // we have a new value in the array at parser.depth - 1
420+
doc_parser.increment_count(doc_parser.containing_scope[parser.depth - 1]); // we have a new value in the array at parser.depth - 1
421421

422422
main_array_switch:
423423
/* we call update char on all paths in, so we can peek at parser.c on the
@@ -427,7 +427,7 @@ WARN_UNUSED error_code implementation::stage2(const uint8_t *buf, size_t len, pa
427427
array_continue:
428428
switch (parser.advance_char()) {
429429
case ',':
430-
doc_parser.increment_count(parser.depth - 1); // we have a new value in the array at parser.depth - 1
430+
doc_parser.increment_count(doc_parser.containing_scope[parser.depth - 1]); // we have a new value in the array at parser.depth - 1
431431
parser.advance_char();
432432
goto main_array_switch;
433433
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(parser.depth - 1); // we have a key value pair in the object at parser.depth - 1
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
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(parser.depth - 1); // we have a new value in the array at parser.depth - 1
128+
doc_parser.increment_count(doc_parser.containing_scope[parser.depth - 1]); // we have a new value in the array at parser.depth - 1
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(parser.depth - 1); // we have a new value in the array at parser.depth - 1
138+
doc_parser.increment_count(doc_parser.containing_scope[parser.depth - 1]); // we have a new value in the array at parser.depth - 1
139139
parser.advance_char();
140140
goto main_array_switch;
141141
case ']':

0 commit comments

Comments
 (0)