Skip to content

feat(json_decoder): Add items_count to the json_decoder constructor #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions include/jsoncons/json_decoder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ class json_decoder final : public basic_json_visitor<typename Json::char_type>

public:
json_decoder(const allocator_type& alloc = allocator_type(),
const temp_allocator_type& temp_alloc = temp_allocator_type())
const temp_allocator_type& temp_alloc = temp_allocator_type(),
size_t items_count = 1000)
: allocator_(alloc),
result_(),
index_(0),
Expand All @@ -75,9 +76,7 @@ class json_decoder final : public basic_json_visitor<typename Json::char_type>
structure_stack_(temp_alloc),
is_valid_(false)
{
item_stack_.reserve(1000);
structure_stack_.reserve(100);
structure_stack_.emplace_back(structure_type::root_t, 0);
Initialize(items_count, items_count / 10);
}

json_decoder(temp_allocator_arg_t,
Expand All @@ -90,9 +89,7 @@ class json_decoder final : public basic_json_visitor<typename Json::char_type>
structure_stack_(temp_alloc),
is_valid_(false)
{
item_stack_.reserve(1000);
structure_stack_.reserve(100);
structure_stack_.emplace_back(structure_type::root_t, 0);
Initialize(1000,100);
}

#if !defined(JSONCONS_NO_DEPRECATED)
Expand Down Expand Up @@ -134,6 +131,13 @@ class json_decoder final : public basic_json_visitor<typename Json::char_type>

private:

void Initialize(size_t items_count, size_t structures_count)
{
item_stack_.reserve(items_count);
structure_stack_.reserve(structures_count);
structure_stack_.emplace_back(structure_type::root_t, 0);
}

void visit_flush() override
{
}
Expand Down
Loading