Put parser capacity / max_depth back into parser
This commit is contained in:
parent
ea119a5679
commit
c7935ceed1
|
@ -6,6 +6,8 @@ simdjson_warn_unused simdjson_really_inline error_code parser::allocate(size_t n
|
||||||
if (string_buf && new_capacity == capacity() && new_max_depth == max_depth()) { return SUCCESS; }
|
if (string_buf && new_capacity == capacity() && new_max_depth == max_depth()) { return SUCCESS; }
|
||||||
|
|
||||||
// string_capacity copied from document::allocate
|
// string_capacity copied from document::allocate
|
||||||
|
_capacity = 0;
|
||||||
|
_max_depth = 0;
|
||||||
size_t string_capacity = SIMDJSON_ROUNDUP_N(5 * new_capacity / 3 + SIMDJSON_PADDING, 64);
|
size_t string_capacity = SIMDJSON_ROUNDUP_N(5 * new_capacity / 3 + SIMDJSON_PADDING, 64);
|
||||||
string_buf.reset(new (std::nothrow) uint8_t[string_capacity]);
|
string_buf.reset(new (std::nothrow) uint8_t[string_capacity]);
|
||||||
#if SIMDJSON_API_USAGE_CHECKS
|
#if SIMDJSON_API_USAGE_CHECKS
|
||||||
|
@ -17,6 +19,8 @@ simdjson_warn_unused simdjson_really_inline error_code parser::allocate(size_t n
|
||||||
} else {
|
} else {
|
||||||
SIMDJSON_TRY( simdjson::active_implementation->create_dom_parser_implementation(new_capacity, new_max_depth, implementation) );
|
SIMDJSON_TRY( simdjson::active_implementation->create_dom_parser_implementation(new_capacity, new_max_depth, implementation) );
|
||||||
}
|
}
|
||||||
|
_capacity = new_capacity;
|
||||||
|
_max_depth = new_max_depth;
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,10 +54,10 @@ simdjson_warn_unused simdjson_really_inline simdjson_result<json_iterator> parse
|
||||||
}
|
}
|
||||||
|
|
||||||
simdjson_really_inline size_t parser::capacity() const noexcept {
|
simdjson_really_inline size_t parser::capacity() const noexcept {
|
||||||
return implementation ? implementation->capacity() : 0;
|
return _capacity;
|
||||||
}
|
}
|
||||||
simdjson_really_inline size_t parser::max_depth() const noexcept {
|
simdjson_really_inline size_t parser::max_depth() const noexcept {
|
||||||
return implementation ? implementation->max_depth() : DEFAULT_MAX_DEPTH;
|
return implementation ? _max_depth : DEFAULT_MAX_DEPTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -109,6 +109,8 @@ public:
|
||||||
private:
|
private:
|
||||||
/** @private [for benchmarking access] The implementation to use */
|
/** @private [for benchmarking access] The implementation to use */
|
||||||
std::unique_ptr<internal::dom_parser_implementation> implementation{};
|
std::unique_ptr<internal::dom_parser_implementation> implementation{};
|
||||||
|
size_t _capacity{0};
|
||||||
|
size_t _max_depth{0};
|
||||||
std::unique_ptr<uint8_t[]> string_buf{};
|
std::unique_ptr<uint8_t[]> string_buf{};
|
||||||
#if SIMDJSON_API_USAGE_CHECKS
|
#if SIMDJSON_API_USAGE_CHECKS
|
||||||
std::unique_ptr<token_position[]> start_positions{};
|
std::unique_ptr<token_position[]> start_positions{};
|
||||||
|
|
Loading…
Reference in New Issue