Make tape_builder primary entry point to stage 2
This commit is contained in:
parent
d6339aa015
commit
04d39c0961
|
@ -111,7 +111,6 @@ simdjson_really_inline simd8<bool> must_be_2_3_continuation(const simd8<uint8_t>
|
|||
|
||||
#include "arm64/stringparsing.h"
|
||||
#include "arm64/numberparsing.h"
|
||||
#include "generic/stage2/structural_parser.h"
|
||||
#include "generic/stage2/tape_builder.h"
|
||||
|
||||
//
|
||||
|
@ -145,15 +144,11 @@ SIMDJSON_WARN_UNUSED bool implementation::validate_utf8(const char *buf, size_t
|
|||
}
|
||||
|
||||
SIMDJSON_WARN_UNUSED error_code dom_parser_implementation::stage2(dom::document &_doc) noexcept {
|
||||
doc = &_doc;
|
||||
stage2::tape_builder builder(*doc);
|
||||
return stage2::structural_parser::parse<false>(*this, builder);
|
||||
return stage2::tape_builder::parse_document<false>(*this, _doc);
|
||||
}
|
||||
|
||||
SIMDJSON_WARN_UNUSED error_code dom_parser_implementation::stage2_next(dom::document &_doc) noexcept {
|
||||
doc = &_doc;
|
||||
stage2::tape_builder builder(_doc);
|
||||
return stage2::structural_parser::parse<true>(*this, builder);
|
||||
return stage2::tape_builder::parse_document<true>(*this, _doc);
|
||||
}
|
||||
|
||||
SIMDJSON_WARN_UNUSED error_code dom_parser_implementation::parse(const uint8_t *_buf, size_t _len, dom::document &_doc) noexcept {
|
||||
|
|
|
@ -315,22 +315,17 @@ SIMDJSON_WARN_UNUSED bool implementation::validate_utf8(const char *buf, size_t
|
|||
//
|
||||
#include "fallback/stringparsing.h"
|
||||
#include "fallback/numberparsing.h"
|
||||
#include "generic/stage2/structural_parser.h"
|
||||
#include "generic/stage2/tape_builder.h"
|
||||
|
||||
namespace {
|
||||
namespace SIMDJSON_IMPLEMENTATION {
|
||||
|
||||
SIMDJSON_WARN_UNUSED error_code dom_parser_implementation::stage2(dom::document &_doc) noexcept {
|
||||
doc = &_doc;
|
||||
stage2::tape_builder builder(*doc);
|
||||
return stage2::structural_parser::parse<false>(*this, builder);
|
||||
return stage2::tape_builder::parse_document<false>(*this, _doc);
|
||||
}
|
||||
|
||||
SIMDJSON_WARN_UNUSED error_code dom_parser_implementation::stage2_next(dom::document &_doc) noexcept {
|
||||
doc = &_doc;
|
||||
stage2::tape_builder builder(_doc);
|
||||
return stage2::structural_parser::parse<true>(*this, builder);
|
||||
return stage2::tape_builder::parse_document<true>(*this, _doc);
|
||||
}
|
||||
|
||||
SIMDJSON_WARN_UNUSED error_code dom_parser_implementation::parse(const uint8_t *_buf, size_t _len, dom::document &_doc) noexcept {
|
||||
|
|
|
@ -17,12 +17,7 @@ struct structural_parser : structural_iterator {
|
|||
uint32_t depth{0};
|
||||
|
||||
template<bool STREAMING, typename T>
|
||||
SIMDJSON_WARN_UNUSED simdjson_really_inline error_code parse(T &builder) noexcept;
|
||||
template<bool STREAMING, typename T>
|
||||
SIMDJSON_WARN_UNUSED static simdjson_really_inline error_code parse(dom_parser_implementation &dom_parser, T &builder) noexcept {
|
||||
structural_parser parser(dom_parser, STREAMING ? dom_parser.next_structural_index : 0);
|
||||
return parser.parse<STREAMING>(builder);
|
||||
}
|
||||
SIMDJSON_WARN_UNUSED simdjson_really_inline error_code walk_document(T &builder) noexcept;
|
||||
|
||||
// For non-streaming, to pass an explicit 0 as next_structural, which enables optimizations
|
||||
simdjson_really_inline structural_parser(dom_parser_implementation &_dom_parser, uint32_t start_structural_index)
|
||||
|
@ -90,7 +85,7 @@ struct structural_parser : structural_iterator {
|
|||
}; // struct structural_parser
|
||||
|
||||
template<bool STREAMING, typename T>
|
||||
SIMDJSON_WARN_UNUSED simdjson_really_inline error_code structural_parser::parse(T &builder) noexcept {
|
||||
SIMDJSON_WARN_UNUSED simdjson_really_inline error_code structural_parser::walk_document(T &builder) noexcept {
|
||||
logger::log_start();
|
||||
|
||||
//
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#include "generic/stage2/structural_parser.h"
|
||||
#include "generic/stage2/tape_writer.h"
|
||||
#include "generic/stage2/atomparsing.h"
|
||||
|
||||
|
@ -11,11 +12,21 @@ struct tape_builder {
|
|||
/** Next write location in the string buf for stage 2 parsing */
|
||||
uint8_t *current_string_buf_loc;
|
||||
|
||||
simdjson_really_inline tape_builder(dom::document &doc) noexcept : tape{doc.tape.get()}, current_string_buf_loc{doc.string_buf.get()} {}
|
||||
template<bool STREAMING>
|
||||
SIMDJSON_WARN_UNUSED static simdjson_really_inline error_code parse_document(
|
||||
dom_parser_implementation &dom_parser,
|
||||
dom::document &doc) noexcept {
|
||||
dom_parser.doc = &doc;
|
||||
structural_parser iter(dom_parser, STREAMING ? dom_parser.next_structural_index : 0);
|
||||
tape_builder builder(doc);
|
||||
return iter.walk_document<STREAMING>(builder);
|
||||
}
|
||||
|
||||
private:
|
||||
friend struct structural_parser;
|
||||
|
||||
simdjson_really_inline tape_builder(dom::document &doc) noexcept : tape{doc.tape.get()}, current_string_buf_loc{doc.string_buf.get()} {}
|
||||
|
||||
simdjson_really_inline error_code parse_root_primitive(structural_parser &parser, const uint8_t *value) {
|
||||
switch (*value) {
|
||||
case '"': return parse_string(parser, value);
|
||||
|
|
|
@ -80,7 +80,6 @@ simdjson_really_inline simd8<bool> must_be_2_3_continuation(const simd8<uint8_t>
|
|||
//
|
||||
#include "haswell/stringparsing.h"
|
||||
#include "haswell/numberparsing.h"
|
||||
#include "generic/stage2/structural_parser.h"
|
||||
#include "generic/stage2/tape_builder.h"
|
||||
|
||||
//
|
||||
|
@ -112,15 +111,11 @@ SIMDJSON_WARN_UNUSED bool implementation::validate_utf8(const char *buf, size_t
|
|||
}
|
||||
|
||||
SIMDJSON_WARN_UNUSED error_code dom_parser_implementation::stage2(dom::document &_doc) noexcept {
|
||||
doc = &_doc;
|
||||
stage2::tape_builder builder(_doc);
|
||||
return stage2::structural_parser::parse<false>(*this, builder);
|
||||
return stage2::tape_builder::parse_document<false>(*this, _doc);
|
||||
}
|
||||
|
||||
SIMDJSON_WARN_UNUSED error_code dom_parser_implementation::stage2_next(dom::document &_doc) noexcept {
|
||||
doc = &_doc;
|
||||
stage2::tape_builder builder(_doc);
|
||||
return stage2::structural_parser::parse<true>(*this, builder);
|
||||
return stage2::tape_builder::parse_document<true>(*this, _doc);
|
||||
}
|
||||
|
||||
SIMDJSON_WARN_UNUSED error_code dom_parser_implementation::parse(const uint8_t *_buf, size_t _len, dom::document &_doc) noexcept {
|
||||
|
|
|
@ -81,7 +81,6 @@ simdjson_really_inline simd8<bool> must_be_2_3_continuation(const simd8<uint8_t>
|
|||
//
|
||||
#include "westmere/stringparsing.h"
|
||||
#include "westmere/numberparsing.h"
|
||||
#include "generic/stage2/structural_parser.h"
|
||||
#include "generic/stage2/tape_builder.h"
|
||||
|
||||
//
|
||||
|
@ -114,15 +113,11 @@ SIMDJSON_WARN_UNUSED bool implementation::validate_utf8(const char *buf, size_t
|
|||
}
|
||||
|
||||
SIMDJSON_WARN_UNUSED error_code dom_parser_implementation::stage2(dom::document &_doc) noexcept {
|
||||
doc = &_doc;
|
||||
stage2::tape_builder builder(*doc);
|
||||
return stage2::structural_parser::parse<false>(*this, builder);
|
||||
return stage2::tape_builder::parse_document<false>(*this, _doc);
|
||||
}
|
||||
|
||||
SIMDJSON_WARN_UNUSED error_code dom_parser_implementation::stage2_next(dom::document &_doc) noexcept {
|
||||
doc = &_doc;
|
||||
stage2::tape_builder builder(_doc);
|
||||
return stage2::structural_parser::parse<true>(*this, builder);
|
||||
return stage2::tape_builder::parse_document<true>(*this, _doc);
|
||||
}
|
||||
|
||||
SIMDJSON_WARN_UNUSED error_code dom_parser_implementation::parse(const uint8_t *_buf, size_t _len, dom::document &_doc) noexcept {
|
||||
|
|
Loading…
Reference in New Issue