Don't set parser.valid or parser.error
This regresses performance and is ONLY here because the next two commits are here; this lets us see the impact of removing parser.error separately from the impact of the next commit.
This commit is contained in:
parent
db2cb061cb
commit
86f8a4a9d2
|
@ -12,7 +12,7 @@ struct streaming_structural_parser: structural_parser {
|
||||||
advance_char();
|
advance_char();
|
||||||
// Push the root scope (there is always at least one scope)
|
// Push the root scope (there is always at least one scope)
|
||||||
if (start_document(finish_parser)) {
|
if (start_document(finish_parser)) {
|
||||||
return parser.error = DEPTH_ERROR;
|
return DEPTH_ERROR;
|
||||||
}
|
}
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -21,20 +21,20 @@ struct streaming_structural_parser: structural_parser {
|
||||||
WARN_UNUSED really_inline error_code finish() {
|
WARN_UNUSED really_inline error_code finish() {
|
||||||
if ( structurals.past_end(parser.n_structural_indexes) ) {
|
if ( structurals.past_end(parser.n_structural_indexes) ) {
|
||||||
log_error("IMPOSSIBLE: past the end of the JSON!");
|
log_error("IMPOSSIBLE: past the end of the JSON!");
|
||||||
return parser.error = TAPE_ERROR;
|
return TAPE_ERROR;
|
||||||
}
|
}
|
||||||
end_document();
|
end_document();
|
||||||
if (depth != 0) {
|
if (depth != 0) {
|
||||||
log_error("Unclosed objects or arrays!");
|
log_error("Unclosed objects or arrays!");
|
||||||
return parser.error = TAPE_ERROR;
|
return TAPE_ERROR;
|
||||||
}
|
}
|
||||||
if (parser.containing_scope[depth].tape_index != 0) {
|
if (parser.containing_scope[depth].tape_index != 0) {
|
||||||
log_error("IMPOSSIBLE: root scope tape index did not start at 0!");
|
log_error("IMPOSSIBLE: root scope tape index did not start at 0!");
|
||||||
return parser.error = TAPE_ERROR;
|
return TAPE_ERROR;
|
||||||
}
|
}
|
||||||
bool finished = structurals.at_end(parser.n_structural_indexes);
|
bool finished = structurals.at_end(parser.n_structural_indexes);
|
||||||
if (!finished) { log_value("(and has more)"); }
|
if (!finished) { log_value("(and has more)"); }
|
||||||
return on_success(finished ? SUCCESS : SUCCESS_AND_HAS_MORE);
|
return finished ? SUCCESS : SUCCESS_AND_HAS_MORE;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -274,25 +274,19 @@ struct structural_parser {
|
||||||
// the string might not be NULL terminated.
|
// the string might not be NULL terminated.
|
||||||
if ( !structurals.at_end(parser.n_structural_indexes) ) {
|
if ( !structurals.at_end(parser.n_structural_indexes) ) {
|
||||||
log_error("More than one JSON value at the root of the document, or extra characters at the end of the JSON!");
|
log_error("More than one JSON value at the root of the document, or extra characters at the end of the JSON!");
|
||||||
return parser.error = TAPE_ERROR;
|
return TAPE_ERROR;
|
||||||
}
|
}
|
||||||
end_document();
|
end_document();
|
||||||
if (depth != 0) {
|
if (depth != 0) {
|
||||||
log_error("Unclosed objects or arrays!");
|
log_error("Unclosed objects or arrays!");
|
||||||
return parser.error = TAPE_ERROR;
|
return TAPE_ERROR;
|
||||||
}
|
}
|
||||||
if (parser.containing_scope[depth].tape_index != 0) {
|
if (parser.containing_scope[depth].tape_index != 0) {
|
||||||
log_error("IMPOSSIBLE: root scope tape index did not start at 0!");
|
log_error("IMPOSSIBLE: root scope tape index did not start at 0!");
|
||||||
return parser.error = TAPE_ERROR;
|
return TAPE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
return on_success(SUCCESS);
|
return SUCCESS;
|
||||||
}
|
|
||||||
|
|
||||||
really_inline error_code on_success(error_code success_code) noexcept {
|
|
||||||
parser.error = success_code;
|
|
||||||
parser.valid = true;
|
|
||||||
return success_code;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WARN_UNUSED really_inline error_code error() {
|
WARN_UNUSED really_inline error_code error() {
|
||||||
|
@ -307,11 +301,11 @@ struct structural_parser {
|
||||||
* carefully,
|
* carefully,
|
||||||
* all without any added cost. */
|
* all without any added cost. */
|
||||||
if (depth >= parser.max_depth()) {
|
if (depth >= parser.max_depth()) {
|
||||||
return parser.error = DEPTH_ERROR;
|
return DEPTH_ERROR;
|
||||||
}
|
}
|
||||||
switch (structurals.current_char()) {
|
switch (structurals.current_char()) {
|
||||||
case '"':
|
case '"':
|
||||||
return parser.error = STRING_ERROR;
|
return STRING_ERROR;
|
||||||
case '0':
|
case '0':
|
||||||
case '1':
|
case '1':
|
||||||
case '2':
|
case '2':
|
||||||
|
@ -323,23 +317,21 @@ struct structural_parser {
|
||||||
case '8':
|
case '8':
|
||||||
case '9':
|
case '9':
|
||||||
case '-':
|
case '-':
|
||||||
return parser.error = NUMBER_ERROR;
|
return NUMBER_ERROR;
|
||||||
case 't':
|
case 't':
|
||||||
return parser.error = T_ATOM_ERROR;
|
return T_ATOM_ERROR;
|
||||||
case 'n':
|
case 'n':
|
||||||
return parser.error = N_ATOM_ERROR;
|
return N_ATOM_ERROR;
|
||||||
case 'f':
|
case 'f':
|
||||||
return parser.error = F_ATOM_ERROR;
|
return F_ATOM_ERROR;
|
||||||
default:
|
default:
|
||||||
return parser.error = TAPE_ERROR;
|
return TAPE_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
really_inline void init() {
|
really_inline void init() {
|
||||||
current_string_buf_loc = parser.doc.string_buf.get();
|
current_string_buf_loc = parser.doc.string_buf.get();
|
||||||
parser.current_loc = 0;
|
parser.current_loc = 0;
|
||||||
parser.valid = false;
|
|
||||||
parser.error = UNINITIALIZED;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WARN_UNUSED really_inline error_code start(size_t len, ret_address finish_state) {
|
WARN_UNUSED really_inline error_code start(size_t len, ret_address finish_state) {
|
||||||
|
@ -352,7 +344,7 @@ struct structural_parser {
|
||||||
structurals.advance_char();
|
structurals.advance_char();
|
||||||
// Push the root scope (there is always at least one scope)
|
// Push the root scope (there is always at least one scope)
|
||||||
if (start_document(finish_state)) {
|
if (start_document(finish_state)) {
|
||||||
return parser.error = DEPTH_ERROR;
|
return DEPTH_ERROR;
|
||||||
}
|
}
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue