Still need to streamline number parsing.

This commit is contained in:
Daniel Lemire 2018-11-29 17:56:17 -05:00
parent c1de7662c1
commit ce85dd0c3a
2 changed files with 9 additions and 15 deletions

View File

@ -108,7 +108,6 @@ public:
int64_t intval; int64_t intval;
double doubleval; double doubleval;
for (; tapeidx < howmany; tapeidx++) { for (; tapeidx < howmany; tapeidx++) {
// printf("\ncounter: %d\n", tapeidx);
tape_val = tape[tapeidx]; tape_val = tape[tapeidx];
u64 payload = tape_val & JSONVALUEMASK; u64 payload = tape_val & JSONVALUEMASK;
type = (tape_val >> 56); type = (tape_val >> 56);

View File

@ -183,9 +183,6 @@ start_continue:
object_begin: object_begin:
DEBUG_PRINTF("in object_begin\n"); DEBUG_PRINTF("in object_begin\n");
pj.containing_scope_offset[depth] = pj.get_current_loc();
//pj.write_tape(0, c); // this is a bad spot to do this performance-wise
UPDATE_CHAR(); UPDATE_CHAR();
switch (c) { switch (c) {
case '"': { case '"': {
@ -254,7 +251,8 @@ object_key_state:
break; break;
} }
case '{': { case '{': {
pj.write_tape(0, c); // strangely, moving this to object_begin slows things down pj.containing_scope_offset[depth] = pj.get_current_loc();
pj.write_tape(0, c); // here the compilers knows what c is so this gets optimized
// we have not yet encountered } so we need to come back for it // we have not yet encountered } so we need to come back for it
pj.ret_address[depth] = &&object_continue; pj.ret_address[depth] = &&object_continue;
// we found an object inside an object, so we need to increment the depth // we found an object inside an object, so we need to increment the depth
@ -266,7 +264,8 @@ object_key_state:
goto object_begin; goto object_begin;
} }
case '[': { case '[': {
pj.write_tape(0, c); // strangely, moving this to array_begin slows things down pj.containing_scope_offset[depth] = pj.get_current_loc();
pj.write_tape(0, c); // here the compilers knows what c is so this gets optimized
// we have not yet encountered } so we need to come back for it // we have not yet encountered } so we need to come back for it
pj.ret_address[depth] = &&object_continue; pj.ret_address[depth] = &&object_continue;
// we found an array inside an object, so we need to increment the depth // we found an array inside an object, so we need to increment the depth
@ -314,7 +313,7 @@ scope_end:
////////////////////////////// ARRAY STATES ///////////////////////////// ////////////////////////////// ARRAY STATES /////////////////////////////
array_begin: array_begin:
DEBUG_PRINTF("in array_begin\n"); DEBUG_PRINTF("in array_begin\n");
pj.containing_scope_offset[depth] = pj.get_current_loc(); //pj.containing_scope_offset[depth] = pj.get_current_loc();
UPDATE_CHAR(); UPDATE_CHAR();
if (c == ']') { if (c == ']') {
goto scope_end; // could also go to array_continue goto scope_end; // could also go to array_continue
@ -372,7 +371,8 @@ main_array_switch:
} }
case '{': { case '{': {
// we have not yet encountered ] so we need to come back for it // we have not yet encountered ] so we need to come back for it
pj.write_tape(0, c); // strangely, moving this to object_begin slows things down pj.containing_scope_offset[depth] = pj.get_current_loc();
pj.write_tape(0, c); // here the compilers knows what c is so this gets optimized
pj.ret_address[depth] = &&array_continue; pj.ret_address[depth] = &&array_continue;
// we found an object inside an array, so we need to increment the depth // we found an object inside an array, so we need to increment the depth
depth++; depth++;
@ -384,7 +384,8 @@ main_array_switch:
} }
case '[': { case '[': {
// we have not yet encountered ] so we need to come back for it // we have not yet encountered ] so we need to come back for it
pj.write_tape(0, c); // strangely, moving this to array_begin slows things down pj.containing_scope_offset[depth] = pj.get_current_loc();
pj.write_tape(0, c); // here the compilers knows what c is so this gets optimized
pj.ret_address[depth] = &&array_continue; pj.ret_address[depth] = &&array_continue;
// we found an array inside an array, so we need to increment the depth // we found an array inside an array, so we need to increment the depth
depth++; depth++;
@ -414,12 +415,6 @@ array_continue:
succeed: succeed:
DEBUG_PRINTF("in succeed, depth = %d \n", depth); DEBUG_PRINTF("in succeed, depth = %d \n", depth);
// we annotate the root node
// depth--;
// next line tells the root node how to go to the end
pj.annotate_previousloc(pj.containing_scope_offset[depth],
pj.get_current_loc());
// next line allows us to go back to the start
if(depth != 0) { if(depth != 0) {
printf("internal bug\n"); printf("internal bug\n");
abort(); abort();