@@ -183,9 +183,6 @@ bool unified_machine(const u8 *buf, size_t len, ParsedJson &pj) {
183183
184184object_begin:
185185 DEBUG_PRINTF (" in object_begin\n " );
186- pj.containing_scope_offset [depth] = pj.get_current_loc ();
187- // pj.write_tape(0, c); // this is a bad spot to do this performance-wise
188-
189186 UPDATE_CHAR ();
190187 switch (c) {
191188 case ' "' : {
@@ -254,7 +251,8 @@ bool unified_machine(const u8 *buf, size_t len, ParsedJson &pj) {
254251 break ;
255252 }
256253 case ' {' : {
257- pj.write_tape (0 , c); // strangely, moving this to object_begin slows things down
254+ pj.containing_scope_offset [depth] = pj.get_current_loc ();
255+ pj.write_tape (0 , c); // here the compilers knows what c is so this gets optimized
258256 // we have not yet encountered } so we need to come back for it
259257 pj.ret_address [depth] = &&object_continue;
260258 // we found an object inside an object, so we need to increment the depth
@@ -266,7 +264,8 @@ bool unified_machine(const u8 *buf, size_t len, ParsedJson &pj) {
266264 goto object_begin;
267265 }
268266 case ' [' : {
269- pj.write_tape (0 , c); // strangely, moving this to array_begin slows things down
267+ pj.containing_scope_offset [depth] = pj.get_current_loc ();
268+ pj.write_tape (0 , c); // here the compilers knows what c is so this gets optimized
270269 // we have not yet encountered } so we need to come back for it
271270 pj.ret_address [depth] = &&object_continue;
272271 // we found an array inside an object, so we need to increment the depth
@@ -314,7 +313,7 @@ bool unified_machine(const u8 *buf, size_t len, ParsedJson &pj) {
314313 // //////////////////////////// ARRAY STATES /////////////////////////////
315314array_begin:
316315 DEBUG_PRINTF (" in array_begin\n " );
317- pj.containing_scope_offset [depth] = pj.get_current_loc ();
316+ // pj.containing_scope_offset[depth] = pj.get_current_loc();
318317 UPDATE_CHAR ();
319318 if (c == ' ]' ) {
320319 goto scope_end; // could also go to array_continue
@@ -372,7 +371,8 @@ bool unified_machine(const u8 *buf, size_t len, ParsedJson &pj) {
372371 }
373372 case ' {' : {
374373 // we have not yet encountered ] so we need to come back for it
375- pj.write_tape (0 , c); // strangely, moving this to object_begin slows things down
374+ pj.containing_scope_offset [depth] = pj.get_current_loc ();
375+ pj.write_tape (0 , c); // here the compilers knows what c is so this gets optimized
376376 pj.ret_address [depth] = &&array_continue;
377377 // we found an object inside an array, so we need to increment the depth
378378 depth++;
@@ -384,7 +384,8 @@ bool unified_machine(const u8 *buf, size_t len, ParsedJson &pj) {
384384 }
385385 case ' [' : {
386386 // we have not yet encountered ] so we need to come back for it
387- pj.write_tape (0 , c); // strangely, moving this to array_begin slows things down
387+ pj.containing_scope_offset [depth] = pj.get_current_loc ();
388+ pj.write_tape (0 , c); // here the compilers knows what c is so this gets optimized
388389 pj.ret_address [depth] = &&array_continue;
389390 // we found an array inside an array, so we need to increment the depth
390391 depth++;
@@ -414,12 +415,6 @@ bool unified_machine(const u8 *buf, size_t len, ParsedJson &pj) {
414415
415416succeed:
416417 DEBUG_PRINTF (" in succeed, depth = %d \n " , depth);
417- // we annotate the root node
418- // depth--;
419- // next line tells the root node how to go to the end
420- pj.annotate_previousloc (pj.containing_scope_offset [depth],
421- pj.get_current_loc ());
422- // next line allows us to go back to the start
423418 if (depth != 0 ) {
424419 printf (" internal bug\n " );
425420 abort ();
0 commit comments