@@ -50,51 +50,51 @@ struct structural_parser {
50
50
return doc_parser ().doc ;
51
51
}
52
52
53
- WARN_UNUSED really_inline bool start_scope (internal::tape_type type ) {
53
+ WARN_UNUSED really_inline bool start_scope () {
54
54
bool exceeded_max_depth = depth >= doc_parser ().max_depth ();
55
55
if (exceeded_max_depth) { log_error (" Exceeded max depth!" ); return true ; }
56
- write_tape ( 0 , type); // if the document is correct, this gets rewritten later
56
+ doc_parser (). current_loc ++;
57
57
return false ;
58
58
}
59
59
60
60
WARN_UNUSED really_inline bool start_document () {
61
61
log_start_value (" document" );
62
- return start_scope (internal::tape_type::ROOT );
62
+ return start_scope ();
63
63
}
64
64
65
65
WARN_UNUSED really_inline bool start_object () {
66
66
log_start_value (" object" );
67
- return start_scope (internal::tape_type::START_OBJECT );
67
+ return start_scope ();
68
68
}
69
69
70
70
WARN_UNUSED really_inline bool start_array () {
71
71
log_start_value (" array" );
72
- return start_scope (internal::tape_type::START_ARRAY );
72
+ return start_scope ();
73
73
}
74
74
75
75
// this function is responsible for annotating the start of the scope
76
- really_inline void end_scope (internal::tape_type type , uint32_t start_loc, uint32_t count) noexcept {
76
+ really_inline void end_scope (internal::tape_type start, internal::tape_type end , uint32_t start_loc, uint32_t count) noexcept {
77
77
// write our doc.tape location to the header scope
78
78
// The root scope gets written *at* the previous location.
79
- write_tape (start_loc, type );
79
+ write_tape (start_loc, end );
80
80
// count can overflow if it exceeds 24 bits... so we saturate
81
81
// the convention being that a cnt of 0xffffff or more is undetermined in value (>= 0xffffff).
82
82
const uint32_t cntsat = count > 0xFFFFFF ? 0xFFFFFF : count;
83
83
// This is a load and an OR. It would be possible to just write once at doc.tape[d.tape_index]
84
- doc ().tape [start_loc] | = doc_parser ().current_loc | (uint64_t (cntsat) << 32 );
84
+ doc ().tape [start_loc] = doc_parser ().current_loc | (uint64_t (cntsat) << 32 ) | (( uint64_t ( char (start))) << 56 );
85
85
}
86
86
87
87
really_inline void end_object (uint32_t start_loc, uint32_t count) {
88
88
log_end_value (" object" );
89
- end_scope (internal::tape_type::END_OBJECT, start_loc, count);
89
+ end_scope (internal::tape_type::START_OBJECT, internal::tape_type:: END_OBJECT, start_loc, count);
90
90
}
91
91
really_inline void end_array (uint32_t start_loc, uint32_t count) {
92
92
log_end_value (" array" );
93
- end_scope (internal::tape_type::END_ARRAY, start_loc, count);
93
+ end_scope (internal::tape_type::START_ARRAY, internal::tape_type:: END_ARRAY, start_loc, count);
94
94
}
95
95
really_inline void end_document (uint32_t start_loc, uint32_t count) {
96
96
log_end_value (" document" );
97
- end_scope (internal::tape_type::ROOT, start_loc, count);
97
+ end_scope (internal::tape_type::ROOT, internal::tape_type::ROOT, start_loc, count);
98
98
}
99
99
100
100
really_inline void write_tape (uint64_t val, internal::tape_type t) noexcept {
0 commit comments