Skip to content

Commit f3ec75f

Browse files
committed
temp
1 parent 4b1c42f commit f3ec75f

File tree

1 file changed

+87
-132
lines changed

1 file changed

+87
-132
lines changed

include/boost/json/basic_parser_impl.hpp

+87-132
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,8 @@ parse_document(const char* p, PrevState st)
548548
goto do_doc3;
549549
case state::com1: case state::com2:
550550
case state::com3: case state::com4:
551-
goto do_doc4;
551+
cs = parse_comment( cs.begin(), st, std::true_type() );
552+
goto after_doc4;
552553
}
553554
}
554555
do_doc1:
@@ -648,18 +649,8 @@ parse_document(const char* p, PrevState st)
648649
}
649650
else if(opt_.allow_comments && *cs == '/')
650651
{
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:
663654
if(BOOST_JSON_UNLIKELY(incomplete(cs)))
664655
return sentinel();
665656
goto do_doc3;
@@ -1808,16 +1799,54 @@ parse_object(const char* p,
18081799
{
18091800
default: BOOST_JSON_UNREACHABLE();
18101801
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+
}
18131818
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+
}
18151826
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+
}
18171834
case state::obj8: goto do_obj8;
18181835
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+
}
18211850
}
18221851
}
18231852
else
@@ -1848,18 +1877,8 @@ parse_object(const char* p,
18481877
{
18491878
if(allow_comments && *cs == '/')
18501879
{
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:
18631882
if(BOOST_JSON_UNLIKELY(incomplete(cs)))
18641883
return suspend_or_fail(state::obj2, size);
18651884
goto do_obj1;
@@ -1876,20 +1895,8 @@ parse_object(const char* p,
18761895
= BOOST_CURRENT_LOCATION;
18771896
return fail(cs.begin(), error::object_too_large, &loc);
18781897
}
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:
18931900
if(BOOST_JSON_UNLIKELY(incomplete(cs)))
18941901
return suspend_or_fail(state::obj3, size);
18951902
do_obj4:
@@ -1900,18 +1907,8 @@ parse_object(const char* p,
19001907
{
19011908
if(allow_comments && *cs == '/')
19021909
{
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:
19151912
if(BOOST_JSON_UNLIKELY(incomplete(cs)))
19161913
return suspend_or_fail(state::obj5, size);
19171914
goto do_obj4;
@@ -1925,18 +1922,8 @@ parse_object(const char* p,
19251922
cs = detail::count_whitespace(cs.begin(), cs.end());
19261923
if(BOOST_JSON_UNLIKELY(! cs))
19271924
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:
19401927
if(BOOST_JSON_UNLIKELY(incomplete(cs)))
19411928
return suspend_or_fail(state::obj7, size);
19421929
do_obj8:
@@ -1958,18 +1945,8 @@ parse_object(const char* p,
19581945
{
19591946
if(allow_comments && *cs == '/')
19601947
{
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:
19731950
if(BOOST_JSON_UNLIKELY(incomplete(cs)))
19741951
return suspend_or_fail(state::obj10, size);
19751952
goto do_obj9;
@@ -1983,18 +1960,8 @@ parse_object(const char* p,
19831960
{
19841961
if(allow_comments && *cs == '/')
19851962
{
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:
19981965
if(BOOST_JSON_UNLIKELY(incomplete(cs)))
19991966
return suspend_or_fail(state::obj11, size);
20001967
goto do_obj8;
@@ -2038,11 +2005,29 @@ parse_array(
20382005
{
20392006
default: BOOST_JSON_UNREACHABLE();
20402007
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+
}
20432022
case state::arr4: goto do_arr4;
20442023
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+
}
20462031
}
20472032
}
20482033
else
@@ -2072,18 +2057,8 @@ parse_array(
20722057
loop:
20732058
if(allow_comments && *cs == '/')
20742059
{
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:
20872062
if(BOOST_JSON_UNLIKELY(incomplete(cs)))
20882063
return suspend_or_fail(state::arr2, size);
20892064
goto do_arr1;
@@ -2095,19 +2070,9 @@ parse_array(
20952070
= BOOST_CURRENT_LOCATION;
20962071
return fail(cs.begin(), error::array_too_large, &loc);
20972072
}
2098-
do_arr3:
20992073
// 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:
21112076
if(BOOST_JSON_UNLIKELY(incomplete(cs)))
21122077
return suspend_or_fail(state::arr3, size);
21132078
do_arr4:
@@ -2129,18 +2094,8 @@ parse_array(
21292094
{
21302095
if(allow_comments && *cs == '/')
21312096
{
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:
21442099
if(BOOST_JSON_UNLIKELY(incomplete(cs)))
21452100
return suspend_or_fail(state::arr6, size);
21462101
goto do_arr4;

0 commit comments

Comments
 (0)