diff --git a/include/jsoncons/bigint.hpp b/include/jsoncons/bigint.hpp index 874d16649..9d2a39846 100644 --- a/include/jsoncons/bigint.hpp +++ b/include/jsoncons/bigint.hpp @@ -203,14 +203,23 @@ class basic_bigint : protected detail::basic_bigint_base { } - 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::allocate(alloc, capacity_); + JSONCONS_TRY + { + std::allocator_traits::construct(alloc, extension_traits::to_plain_pointer(data_)); + } + JSONCONS_CATCH(...) + { + std::allocator_traits::deallocate(alloc, data_, capacity_); + JSONCONS_RETHROW; + } std::memcpy(data_, stor.data_, size_type(stor.length_*sizeof(uint64_t))); } @@ -226,21 +235,6 @@ class basic_bigint : protected detail::basic_bigint_base stor.data_ = nullptr; } - void create(size_type length, real_allocator_type alloc) - { - capacity_ = round_up(length); - data_ = std::allocator_traits::allocate(alloc, capacity_); - JSONCONS_TRY - { - std::allocator_traits::construct(alloc, extension_traits::to_plain_pointer(data_)); - } - JSONCONS_CATCH(...) - { - std::allocator_traits::deallocate(alloc, data_, capacity_); - JSONCONS_RETHROW; - } - } - void destroy(const real_allocator_type& a) noexcept { if (data_ != nullptr) @@ -271,7 +265,7 @@ class basic_bigint : protected detail::basic_bigint_base } // 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; } diff --git a/include/jsoncons/json_parser.hpp b/include/jsoncons/json_parser.hpp index 7b70de4ba..d3d6634dc 100644 --- a/include/jsoncons/json_parser.hpp +++ b/include/jsoncons/json_parser.hpp @@ -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) diff --git a/include/jsoncons/json_reader.hpp b/include/jsoncons/json_reader.hpp index 868e5eab7..e4d3a8c12 100644 --- a/include/jsoncons/json_reader.hpp +++ b/include/jsoncons/json_reader.hpp @@ -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; - } } }