@@ -63,6 +63,9 @@ class structural_iterator {
6363 really_inline const uint8_t * current () {
6464 return &buf[idx];
6565 }
66+ really_inline size_t remaining_len () {
67+ return len - idx;
68+ }
6669 template <typename F>
6770 really_inline bool with_space_terminated_copy (const F& f) {
6871 /* *
@@ -172,18 +175,18 @@ struct structural_parser {
172175 return parse_number (structurals.current (), found_minus);
173176 }
174177
175- WARN_UNUSED really_inline bool parse_atom (const uint8_t *src ) {
178+ WARN_UNUSED really_inline bool parse_atom () {
176179 switch (structurals.current_char ()) {
177180 case ' t' :
178- if (!is_valid_true_atom (src )) { return true ; }
181+ if (!atomparsing:: is_valid_true_atom (structurals. current () )) { return true ; }
179182 doc_parser.on_true_atom ();
180183 break ;
181184 case ' f' :
182- if (!is_valid_false_atom (src )) { return true ; }
185+ if (!atomparsing:: is_valid_false_atom (structurals. current () )) { return true ; }
183186 doc_parser.on_false_atom ();
184187 break ;
185188 case ' n' :
186- if (!is_valid_null_atom (src )) { return true ; }
189+ if (!atomparsing:: is_valid_null_atom (structurals. current () )) { return true ; }
187190 doc_parser.on_null_atom ();
188191 break ;
189192 default :
@@ -192,8 +195,24 @@ struct structural_parser {
192195 return false ;
193196 }
194197
195- WARN_UNUSED really_inline bool parse_atom () {
196- return parse_atom (structurals.current ());
198+ WARN_UNUSED really_inline bool parse_single_atom () {
199+ switch (structurals.current_char ()) {
200+ case ' t' :
201+ if (!atomparsing::is_valid_true_atom (structurals.current (), structurals.remaining_len ())) { return true ; }
202+ doc_parser.on_true_atom ();
203+ break ;
204+ case ' f' :
205+ if (!atomparsing::is_valid_false_atom (structurals.current (), structurals.remaining_len ())) { return true ; }
206+ doc_parser.on_false_atom ();
207+ break ;
208+ case ' n' :
209+ if (!atomparsing::is_valid_null_atom (structurals.current (), structurals.remaining_len ())) { return true ; }
210+ doc_parser.on_null_atom ();
211+ break ;
212+ default :
213+ return true ;
214+ }
215+ return false ;
197216 }
198217
199218 WARN_UNUSED really_inline ret_address parse_value (const unified_machine_addresses &addresses, ret_address continue_state) {
@@ -327,11 +346,7 @@ WARN_UNUSED error_code implementation::stage2(const uint8_t *buf, size_t len, do
327346 FAIL_IF ( parser.parse_string () );
328347 goto finish;
329348 case ' t' : case ' f' : case ' n' :
330- FAIL_IF (
331- parser.structurals .with_space_terminated_copy ([&](auto copy, auto idx) {
332- return parser.parse_atom (©[idx]);
333- })
334- );
349+ FAIL_IF ( parser.parse_single_atom () );
335350 goto finish;
336351 case ' 0' : case ' 1' : case ' 2' : case ' 3' : case ' 4' :
337352 case ' 5' : case ' 6' : case ' 7' : case ' 8' : case ' 9' :
0 commit comments