mirror of
https://github.com/simdjson/simdjson
synced 2026-06-08 17:27:07 +00:00
Return errors immediately instead of using goto
This commit is contained in:
@@ -144,13 +144,12 @@ WARN_UNUSED bool implementation::validate_utf8(const char *buf, size_t len) cons
|
||||
}
|
||||
|
||||
WARN_UNUSED error_code dom_parser_implementation::stage2(dom::document &_doc) noexcept {
|
||||
error_code result = stage2::parse_structurals<false>(*this, _doc);
|
||||
if (result) { return result; }
|
||||
if (auto error = stage2::parse_structurals<false>(*this, _doc)) { return error; }
|
||||
|
||||
// If we didn't make it to the end, it's an error
|
||||
if ( next_structural_index != n_structural_indexes ) {
|
||||
logger::log_string("More than one JSON value at the root of the document, or extra characters at the end of the JSON!");
|
||||
return error = TAPE_ERROR;
|
||||
return TAPE_ERROR;
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
@@ -161,8 +160,8 @@ WARN_UNUSED error_code dom_parser_implementation::stage2_next(dom::document &_do
|
||||
}
|
||||
|
||||
WARN_UNUSED error_code dom_parser_implementation::parse(const uint8_t *_buf, size_t _len, dom::document &_doc) noexcept {
|
||||
error_code err = stage1(_buf, _len, false);
|
||||
if (err) { return err; }
|
||||
auto error = stage1(_buf, _len, false);
|
||||
if (error) { return error; }
|
||||
return stage2(_doc);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user