Skip to content

Commit

Permalink
chunk_reader.hpp
Browse files Browse the repository at this point in the history
  • Loading branch information
danielaparker committed Nov 15, 2024
1 parent 9e6db17 commit f626c58
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 33 deletions.
32 changes: 13 additions & 19 deletions include/jsoncons/bigint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,14 +203,23 @@ class basic_bigint : protected detail::basic_bigint_base<Allocator>
{
}

dynamic_storage(const dynamic_storage& stor, const real_allocator_type& alloc)
dynamic_storage(const dynamic_storage& stor, real_allocator_type alloc)
: is_dynamic_(true),
is_negative_(stor.is_negative_),
length_(stor.length_),
capacity_(0),
capacity_(round_up(stor.length_)),
data_(nullptr)
{
create(stor.length_, alloc);
data_ = std::allocator_traits<real_allocator_type>::allocate(alloc, capacity_);
JSONCONS_TRY
{
std::allocator_traits<real_allocator_type>::construct(alloc, extension_traits::to_plain_pointer(data_));
}
JSONCONS_CATCH(...)
{
std::allocator_traits<real_allocator_type>::deallocate(alloc, data_, capacity_);
JSONCONS_RETHROW;
}
std::memcpy(data_, stor.data_, size_type(stor.length_*sizeof(uint64_t)));
}

Expand All @@ -226,21 +235,6 @@ class basic_bigint : protected detail::basic_bigint_base<Allocator>
stor.data_ = nullptr;
}

void create(size_type length, real_allocator_type alloc)
{
capacity_ = round_up(length);
data_ = std::allocator_traits<real_allocator_type>::allocate(alloc, capacity_);
JSONCONS_TRY
{
std::allocator_traits<real_allocator_type>::construct(alloc, extension_traits::to_plain_pointer(data_));
}
JSONCONS_CATCH(...)
{
std::allocator_traits<real_allocator_type>::deallocate(alloc, data_, capacity_);
JSONCONS_RETHROW;
}
}

void destroy(const real_allocator_type& a) noexcept
{
if (data_ != nullptr)
Expand Down Expand Up @@ -271,7 +265,7 @@ class basic_bigint : protected detail::basic_bigint_base<Allocator>
}

// Find suitable new block size
constexpr size_type round_up(size_type i) const
constexpr size_type round_up(size_type i) const noexcept
{
return (i/word_length + 1) * word_length;
}
Expand Down
1 change: 1 addition & 0 deletions include/jsoncons/json_parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ class basic_json_parser : public ser_context, public virtual basic_parser_input<
void skip_space(std::error_code& ec)
{
const char_type* local_input_end = input_end_;

while (true)
{
if (input_ptr_ == local_input_end)
Expand Down
15 changes: 1 addition & 14 deletions include/jsoncons/json_reader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,22 +319,9 @@ namespace jsoncons {
return;
}

while (!source_.eof())
if (!source_.eof())
{
parser_.skip_whitespace(ec);
if (parser_.source_exhausted())
{
auto s1 = source_.read_buffer(ec);
if (ec) return;
if (s1.size() > 0)
{
parser_.set_buffer(s1.data(),s1.size());
}
}
else
{
break;
}
}
}

Expand Down

0 comments on commit f626c58

Please sign in to comment.