0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-26 15:33:54 +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,11 +204,11 @@ 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,14 +216,14 @@ 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)
| number | (&object_begin >> object(depth + 1))
| lit_true | (&array_begin >> array(depth + 1))
| lit_false | number
| lit_null | lit_true
| object(depth + 1) | lit_false
| array(depth + 1) | lit_null
; ;
} }
}; };