Skip to content

Commit ce85dd0

Browse files
committed
Still need to streamline number parsing.
1 parent c1de766 commit ce85dd0

2 files changed

Lines changed: 9 additions & 15 deletions

File tree

include/jsonparser/simdjson_internal.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ struct ParsedJson {
108108
int64_t intval;
109109
double doubleval;
110110
for (; tapeidx < howmany; tapeidx++) {
111-
// printf("\ncounter: %d\n", tapeidx);
112111
tape_val = tape[tapeidx];
113112
u64 payload = tape_val & JSONVALUEMASK;
114113
type = (tape_val >> 56);

src/stage34_unified.cpp

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,6 @@ bool unified_machine(const u8 *buf, size_t len, ParsedJson &pj) {
183183

184184
object_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 /////////////////////////////
315314
array_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

415416
succeed:
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

Comments
 (0)