diff --git a/include/boost/json/basic_parser.hpp b/include/boost/json/basic_parser.hpp index 19eca177e..8c88dad2f 100644 --- a/include/boost/json/basic_parser.hpp +++ b/include/boost/json/basic_parser.hpp @@ -88,12 +88,12 @@ BOOST_JSON_NS_BEGIN the error code to a suitable value. This error code will be returned by the write function to the caller. -\n +\n Handlers are required to declare the maximum limits on various elements. If these limits are exceeded during parsing, then parsing fails with an error. -\n +\n The following declaration meets the parser's handler requirements: @@ -284,7 +284,7 @@ class basic_parser obj1, obj2, obj3, obj4, obj5, obj6, obj7, obj8, obj9, obj10, obj11, - arr1, arr2, arr3, + arr1, arr2, arr3, arr4, arr5, arr6, num1, num2, num3, num4, num5, num6, num7, num8, @@ -349,21 +349,21 @@ class basic_parser inline const char* fail( - const char* p, + const char* p, error ev) noexcept; BOOST_NOINLINE inline const char* maybe_suspend( - const char* p, + const char* p, state st); BOOST_NOINLINE inline const char* maybe_suspend( - const char* p, + const char* p, state st, std::size_t n); @@ -453,12 +453,12 @@ class basic_parser std::integral_constant stack_empty, std::integral_constant is_key, /*std::integral_constant*/ bool allow_bad_utf8); - + template const char* parse_number(const char* p, std::integral_constant stack_empty, std::integral_constant first); - + template const char* parse_unescaped(const char* p, diff --git a/include/boost/json/detail/stream.hpp b/include/boost/json/detail/stream.hpp index 80ead5e36..1a5b48d4d 100644 --- a/include/boost/json/detail/stream.hpp +++ b/include/boost/json/detail/stream.hpp @@ -15,8 +15,6 @@ namespace detail { class const_stream { - friend class local_const_stream; - char const* p_; char const* end_; @@ -89,36 +87,6 @@ class const_stream } }; -class local_const_stream - : public const_stream -{ - const_stream& src_; - -public: - explicit - local_const_stream( - const_stream& src) noexcept - : const_stream(src) - , src_(src) - { - } - - ~local_const_stream() - { - src_.p_ = p_; - } - - void - clip(std::size_t n) noexcept - { - if(static_cast( - src_.end_ - p_) > n) - end_ = p_ + n; - else - end_ = src_.end_; - } -}; - class const_stream_wrapper { const char*& p_; @@ -158,7 +126,7 @@ class const_stream_wrapper { return p_ < end_; } - + const char* begin() const noexcept { return p_; @@ -239,8 +207,6 @@ class clipped_const_stream class stream { - friend class local_stream; - char* p_; char* end_; @@ -324,26 +290,6 @@ class stream } }; -class local_stream - : public stream -{ - stream& src_; - -public: - explicit - local_stream( - stream& src) - : stream(src) - , src_(src) - { - } - - ~local_stream() - { - src_.p_ = p_; - } -}; - } // detail BOOST_JSON_NS_END diff --git a/include/boost/json/impl/serializer.ipp b/include/boost/json/impl/serializer.ipp index c70a421a9..eedcd452e 100644 --- a/include/boost/json/impl/serializer.ipp +++ b/include/boost/json/impl/serializer.ipp @@ -76,9 +76,8 @@ suspend( template bool serializer:: -write_null(stream& ss0) +write_null(stream& ss) { - local_stream ss(ss0); if(! StackEmpty && ! st_.empty()) { state st; @@ -118,9 +117,8 @@ do_nul4: template bool serializer:: -write_true(stream& ss0) +write_true(stream& ss) { - local_stream ss(ss0); if(! StackEmpty && ! st_.empty()) { state st; @@ -160,9 +158,8 @@ do_tru4: template bool serializer:: -write_false(stream& ss0) +write_false(stream& ss) { - local_stream ss(ss0); if(! StackEmpty && ! st_.empty()) { state st; @@ -208,10 +205,8 @@ do_fal5: template bool serializer:: -write_string(stream& ss0) +write_string(stream& ss) { - local_stream ss(ss0); - local_const_stream cs(cs0_); if(! StackEmpty && ! st_.empty()) { state st; @@ -254,19 +249,19 @@ do_str1: do_str2: if(BOOST_JSON_LIKELY(ss)) { - std::size_t n = cs.remain(); + std::size_t n = cs0_.remain(); if(BOOST_JSON_LIKELY(n > 0)) { if(ss.remain() > n) n = detail::count_unescaped( - cs.data(), n); + cs0_.data(), n); else n = detail::count_unescaped( - cs.data(), ss.remain()); + cs0_.data(), ss.remain()); if(n > 0) { - ss.append(cs.data(), n); - cs.skip(n); + ss.append(cs0_.data(), n); + cs0_.skip(n); if(! ss) return suspend(state::str2); } @@ -287,12 +282,12 @@ do_str2: do_str3: while(BOOST_JSON_LIKELY(ss)) { - if(BOOST_JSON_LIKELY(cs)) + if(BOOST_JSON_LIKELY(cs0_)) { - auto const ch = *cs; + auto const ch = *cs0_; auto const c = esc[static_cast< unsigned char>(ch)]; - ++cs; + ++cs0_; if(! c) { ss.append(ch); @@ -385,9 +380,8 @@ do_utf5: template bool serializer:: -write_number(stream& ss0) +write_number(stream& ss) { - local_stream ss(ss0); if(StackEmpty || st_.empty()) { switch(jv_->kind()) @@ -455,10 +449,9 @@ write_number(stream& ss0) template bool serializer:: -write_array(stream& ss0) +write_array(stream& ss) { array const* pa; - local_stream ss(ss0); array::const_iterator it; array::const_iterator end; if(StackEmpty || st_.empty()) @@ -521,10 +514,9 @@ do_arr4: template bool serializer:: -write_object(stream& ss0) +write_object(stream& ss) { object const* po; - local_stream ss(ss0); object::const_iterator it; object::const_iterator end; if(StackEmpty || st_.empty()) diff --git a/include/boost/json/serializer.hpp b/include/boost/json/serializer.hpp index 53bd2d7a3..f90100030 100644 --- a/include/boost/json/serializer.hpp +++ b/include/boost/json/serializer.hpp @@ -59,9 +59,6 @@ class serializer // VFALCO Too many streams using stream = detail::stream; using const_stream = detail::const_stream; - using local_stream = detail::local_stream; - using local_const_stream = - detail::local_const_stream; using fn_t = bool (serializer::*)(stream&);