@@ -548,7 +548,8 @@ parse_document(const char* p, PrevState st)
548
548
goto do_doc3;
549
549
case state::com1: case state::com2:
550
550
case state::com3: case state::com4:
551
- goto do_doc4;
551
+ cs = parse_comment ( cs.begin (), st, std::true_type () );
552
+ goto after_doc4;
552
553
}
553
554
}
554
555
do_doc1:
@@ -648,18 +649,8 @@ parse_document(const char* p, PrevState st)
648
649
}
649
650
else if (opt_.allow_comments && *cs == ' /' )
650
651
{
651
- do_doc4:
652
- if (BOOST_JSON_LIKELY (
653
- st != state::com1 && st != state::com2 &&
654
- st != state::com3 && st != state::com4 ))
655
- {
656
- cs = parse_comment ( cs.begin (), no_state (), std::true_type () );
657
- }
658
- else
659
- {
660
- cs = parse_comment ( cs.begin (), st, std::true_type () );
661
- st = no_state ();
662
- }
652
+ cs = parse_comment ( cs.begin (), no_state (), std::true_type () );
653
+ after_doc4:
663
654
if (BOOST_JSON_UNLIKELY (incomplete (cs)))
664
655
return sentinel ();
665
656
goto do_doc3;
@@ -1808,16 +1799,54 @@ parse_object(const char* p,
1808
1799
{
1809
1800
default : BOOST_JSON_UNREACHABLE ();
1810
1801
case state::obj1: goto do_obj1;
1811
- case state::obj2: goto do_obj2;
1812
- case state::obj3: goto do_obj3;
1802
+ case state::obj2:
1803
+ {
1804
+ state st_c;
1805
+ st_.pop (st_c);
1806
+ cs = parse_comment ( cs.begin (), st_c, std::false_type () );
1807
+ goto after_obj2;
1808
+ }
1809
+ case state::obj3:
1810
+ {
1811
+ state st_c;
1812
+ std::size_t total;
1813
+ st_.pop (st_c);
1814
+ st_.pop (total);
1815
+ cs = parse_string (cs.begin (), st_c, total, std::true_type (), allow_bad_utf8);
1816
+ goto after_obj3;
1817
+ }
1813
1818
case state::obj4: goto do_obj4;
1814
- case state::obj5: goto do_obj5;
1819
+ case state::obj5:
1820
+ {
1821
+ state st_c;
1822
+ st_.pop (st_c);
1823
+ cs = parse_comment ( cs.begin (), st_c, std::false_type () );
1824
+ goto after_obj5;
1825
+ }
1815
1826
case state::obj6: goto do_obj6;
1816
- case state::obj7: goto do_obj7;
1827
+ case state::obj7:
1828
+ {
1829
+ state st_v;
1830
+ st_.pop (st_v);
1831
+ cs = parse_value (cs.begin (), st_v, allow_comments, allow_trailing, allow_bad_utf8);
1832
+ goto after_obj7;
1833
+ }
1817
1834
case state::obj8: goto do_obj8;
1818
1835
case state::obj9: goto do_obj9;
1819
- case state::obj10: goto do_obj10;
1820
- case state::obj11: goto do_obj11;
1836
+ case state::obj10:
1837
+ {
1838
+ state st_c;
1839
+ st_.pop (st_c);
1840
+ cs = parse_comment ( cs.begin (), st_c, std::false_type () );
1841
+ goto after_obj10;
1842
+ }
1843
+ case state::obj11:
1844
+ {
1845
+ state st_c;
1846
+ st_.pop (st_c);
1847
+ cs = parse_comment ( cs.begin (), st_c, std::false_type () );
1848
+ goto after_obj11;
1849
+ }
1821
1850
}
1822
1851
}
1823
1852
else
@@ -1848,18 +1877,8 @@ parse_object(const char* p,
1848
1877
{
1849
1878
if (allow_comments && *cs == ' /' )
1850
1879
{
1851
- do_obj2:
1852
- if ( st != state::obj2 )
1853
- {
1854
- cs = parse_comment ( cs.begin (), no_state (), std::false_type () );
1855
- }
1856
- else
1857
- {
1858
- state st_c;
1859
- st_.pop (st_c);
1860
- cs = parse_comment ( cs.begin (), st_c, std::false_type () );
1861
- st = no_state ();
1862
- }
1880
+ cs = parse_comment ( cs.begin (), no_state (), std::false_type () );
1881
+ after_obj2:
1863
1882
if (BOOST_JSON_UNLIKELY (incomplete (cs)))
1864
1883
return suspend_or_fail (state::obj2, size);
1865
1884
goto do_obj1;
@@ -1876,20 +1895,8 @@ parse_object(const char* p,
1876
1895
= BOOST_CURRENT_LOCATION;
1877
1896
return fail (cs.begin (), error::object_too_large, &loc);
1878
1897
}
1879
- do_obj3:
1880
- if (BOOST_JSON_LIKELY ( st != state::obj3 ))
1881
- {
1882
- cs = parse_string (cs.begin (), no_state (), 0 , std::true_type (), allow_bad_utf8);
1883
- }
1884
- else
1885
- {
1886
- state st_c;
1887
- std::size_t total;
1888
- st_.pop (st_c);
1889
- st_.pop (total);
1890
- cs = parse_string (cs.begin (), st_c, total, std::true_type (), allow_bad_utf8);
1891
- st = no_state ();
1892
- }
1898
+ cs = parse_string (cs.begin (), no_state (), 0 , std::true_type (), allow_bad_utf8);
1899
+ after_obj3:
1893
1900
if (BOOST_JSON_UNLIKELY (incomplete (cs)))
1894
1901
return suspend_or_fail (state::obj3, size);
1895
1902
do_obj4:
@@ -1900,18 +1907,8 @@ parse_object(const char* p,
1900
1907
{
1901
1908
if (allow_comments && *cs == ' /' )
1902
1909
{
1903
- do_obj5:
1904
- if (BOOST_JSON_LIKELY ( st != state::obj5 ))
1905
- {
1906
- cs = parse_comment ( cs.begin (), no_state (), std::false_type () );
1907
- }
1908
- else
1909
- {
1910
- state st_c;
1911
- st_.pop (st_c);
1912
- cs = parse_comment ( cs.begin (), st_c, std::false_type () );
1913
- st = no_state ();
1914
- }
1910
+ cs = parse_comment ( cs.begin (), no_state (), std::false_type () );
1911
+ after_obj5:
1915
1912
if (BOOST_JSON_UNLIKELY (incomplete (cs)))
1916
1913
return suspend_or_fail (state::obj5, size);
1917
1914
goto do_obj4;
@@ -1925,18 +1922,8 @@ parse_object(const char* p,
1925
1922
cs = detail::count_whitespace (cs.begin (), cs.end ());
1926
1923
if (BOOST_JSON_UNLIKELY (! cs))
1927
1924
return maybe_suspend (cs.begin (), state::obj6, size);
1928
- do_obj7:
1929
- if (BOOST_JSON_LIKELY ( st != state::obj7 ))
1930
- {
1931
- cs = parse_value (cs.begin (), no_state (), allow_comments, allow_trailing, allow_bad_utf8);
1932
- }
1933
- else
1934
- {
1935
- state st_v;
1936
- st_.pop (st_v);
1937
- cs = parse_value (cs.begin (), st_v, allow_comments, allow_trailing, allow_bad_utf8);
1938
- st = no_state ();
1939
- }
1925
+ cs = parse_value (cs.begin (), no_state (), allow_comments, allow_trailing, allow_bad_utf8);
1926
+ after_obj7:
1940
1927
if (BOOST_JSON_UNLIKELY (incomplete (cs)))
1941
1928
return suspend_or_fail (state::obj7, size);
1942
1929
do_obj8:
@@ -1958,18 +1945,8 @@ parse_object(const char* p,
1958
1945
{
1959
1946
if (allow_comments && *cs == ' /' )
1960
1947
{
1961
- do_obj10:
1962
- if (BOOST_JSON_LIKELY ( st != state::obj10 ))
1963
- {
1964
- cs = parse_comment ( cs.begin (), no_state (), std::false_type () );
1965
- }
1966
- else
1967
- {
1968
- state st_c;
1969
- st_.pop (st_c);
1970
- cs = parse_comment ( cs.begin (), st_c, std::false_type () );
1971
- st = no_state ();
1972
- }
1948
+ cs = parse_comment ( cs.begin (), no_state (), std::false_type () );
1949
+ after_obj10:
1973
1950
if (BOOST_JSON_UNLIKELY (incomplete (cs)))
1974
1951
return suspend_or_fail (state::obj10, size);
1975
1952
goto do_obj9;
@@ -1983,18 +1960,8 @@ parse_object(const char* p,
1983
1960
{
1984
1961
if (allow_comments && *cs == ' /' )
1985
1962
{
1986
- do_obj11:
1987
- if (BOOST_JSON_LIKELY ( st != state::obj11 ))
1988
- {
1989
- cs = parse_comment ( cs.begin (), no_state (), std::false_type () );
1990
- }
1991
- else
1992
- {
1993
- state st_c;
1994
- st_.pop (st_c);
1995
- cs = parse_comment ( cs.begin (), st_c, std::false_type () );
1996
- st = no_state ();
1997
- }
1963
+ cs = parse_comment ( cs.begin (), no_state (), std::false_type () );
1964
+ after_obj11:
1998
1965
if (BOOST_JSON_UNLIKELY (incomplete (cs)))
1999
1966
return suspend_or_fail (state::obj11, size);
2000
1967
goto do_obj8;
@@ -2038,11 +2005,29 @@ parse_array(
2038
2005
{
2039
2006
default : BOOST_JSON_UNREACHABLE ();
2040
2007
case state::arr1: goto do_arr1;
2041
- case state::arr2: goto do_arr2;
2042
- case state::arr3: goto do_arr3;
2008
+ case state::arr2:
2009
+ {
2010
+ state st_c;
2011
+ st_.pop (st_c);
2012
+ cs = parse_comment ( cs.begin (), st_c, std::false_type () );
2013
+ goto after_arr2;
2014
+ }
2015
+ case state::arr3:
2016
+ {
2017
+ state st_v;
2018
+ st_.pop (st_v);
2019
+ cs = parse_value (cs.begin (), st_v, allow_comments, allow_trailing, allow_bad_utf8);
2020
+ goto after_arr3;
2021
+ }
2043
2022
case state::arr4: goto do_arr4;
2044
2023
case state::arr5: goto do_arr5;
2045
- case state::arr6: goto do_arr6;
2024
+ case state::arr6:
2025
+ {
2026
+ state st_c;
2027
+ st_.pop (st_c);
2028
+ cs = parse_comment ( cs.begin (), st_c, std::false_type () );
2029
+ goto after_arr6;
2030
+ }
2046
2031
}
2047
2032
}
2048
2033
else
@@ -2072,18 +2057,8 @@ parse_array(
2072
2057
loop:
2073
2058
if (allow_comments && *cs == ' /' )
2074
2059
{
2075
- do_arr2:
2076
- if (BOOST_JSON_LIKELY ( st != state::arr2 ))
2077
- {
2078
- cs = parse_comment ( cs.begin (), no_state (), std::false_type () );
2079
- }
2080
- else
2081
- {
2082
- state st_c;
2083
- st_.pop (st_c);
2084
- cs = parse_comment ( cs.begin (), st_c, std::false_type () );
2085
- st = no_state ();
2086
- }
2060
+ cs = parse_comment ( cs.begin (), no_state (), std::false_type () );
2061
+ after_arr2:
2087
2062
if (BOOST_JSON_UNLIKELY (incomplete (cs)))
2088
2063
return suspend_or_fail (state::arr2, size);
2089
2064
goto do_arr1;
@@ -2095,19 +2070,9 @@ parse_array(
2095
2070
= BOOST_CURRENT_LOCATION;
2096
2071
return fail (cs.begin (), error::array_too_large, &loc);
2097
2072
}
2098
- do_arr3:
2099
2073
// array is not empty, value required
2100
- if (BOOST_JSON_LIKELY ( st != state::arr3 ))
2101
- {
2102
- cs = parse_value (cs.begin (), no_state (), allow_comments, allow_trailing, allow_bad_utf8);
2103
- }
2104
- else
2105
- {
2106
- state st_v;
2107
- st_.pop (st_v);
2108
- cs = parse_value (cs.begin (), st_v, allow_comments, allow_trailing, allow_bad_utf8);
2109
- st = no_state ();
2110
- }
2074
+ cs = parse_value (cs.begin (), no_state (), allow_comments, allow_trailing, allow_bad_utf8);
2075
+ after_arr3:
2111
2076
if (BOOST_JSON_UNLIKELY (incomplete (cs)))
2112
2077
return suspend_or_fail (state::arr3, size);
2113
2078
do_arr4:
@@ -2129,18 +2094,8 @@ parse_array(
2129
2094
{
2130
2095
if (allow_comments && *cs == ' /' )
2131
2096
{
2132
- do_arr6:
2133
- if (BOOST_JSON_LIKELY ( st != state::arr6 ))
2134
- {
2135
- cs = parse_comment ( cs.begin (), no_state (), std::false_type () );
2136
- }
2137
- else
2138
- {
2139
- state st_c;
2140
- st_.pop (st_c);
2141
- cs = parse_comment ( cs.begin (), st_c, std::false_type () );
2142
- st = no_state ();
2143
- }
2097
+ cs = parse_comment ( cs.begin (), no_state (), std::false_type () );
2098
+ after_arr6:
2144
2099
if (BOOST_JSON_UNLIKELY (incomplete (cs)))
2145
2100
return suspend_or_fail (state::arr6, size);
2146
2101
goto do_arr4;
0 commit comments