0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-27 07:54:05 +01:00

ircd::json: Reduce branch mispredictions in linear_any alternative parser.

This commit is contained in:
Jason Volk 2020-05-13 00:20:57 -07:00
parent 8b3cc178ae
commit a2f6acd73f

View file

@ -181,7 +181,13 @@ ircd::json::input
// primary recursive rule // primary recursive rule
rule<unused_type(uint)> value rule<unused_type(uint)> value
{ {
string | number | lit_true | lit_false | lit_null | object(depth + 1) | array(depth + 1) (&quote >> string)
| (&object_begin >> object(depth + 1))
| (&array_begin >> array(depth + 1))
| number
| lit_true
| lit_false
| lit_null
,"value" ,"value"
}; };
@ -198,9 +204,9 @@ ircd::json::input
rule<enum json::type> type_strict rule<enum json::type> type_strict
{ {
(omit[string] >> attr(json::STRING)) | (omit[&quote >> string] >> attr(json::STRING)) |
(omit[object(0)] >> attr(json::OBJECT)) | (omit[&object_begin >> object(0)] >> attr(json::OBJECT)) |
(omit[array(0)] >> attr(json::ARRAY)) | (omit[&array_begin >> array(0)] >> attr(json::ARRAY)) |
(omit[number] >> attr(json::NUMBER)) | (omit[number] >> attr(json::NUMBER)) |
(omit[literal] >> attr(json::LITERAL)) (omit[literal] >> attr(json::LITERAL))
,"type" ,"type"
@ -210,13 +216,13 @@ ircd::json::input
:input::base_type{rule<>{}} // required by spirit :input::base_type{rule<>{}} // required by spirit
{ {
// synthesized repropagation of recursive rules // synthesized repropagation of recursive rules
value %= string value %= (&quote >> string)
| (&object_begin >> object(depth + 1))
| (&array_begin >> array(depth + 1))
| number | number
| lit_true | lit_true
| lit_false | lit_false
| lit_null | lit_null
| object(depth + 1)
| array(depth + 1)
; ;
} }
}; };