mirror of
https://github.com/matrix-construct/construct
synced 2024-12-26 07:23:53 +01:00
ircd::json: Reduce branch mispredictions in linear_any alternative parser.
This commit is contained in:
parent
8b3cc178ae
commit
a2f6acd73f
1 changed files with 20 additions and 14 deletions
34
ircd/json.cc
34
ircd/json.cc
|
@ -181,7 +181,13 @@ ircd::json::input
|
|||
// primary recursive rule
|
||||
rule<unused_type(uint)> value
|
||||
{
|
||||
string | number | lit_true | lit_false | lit_null | object(depth + 1) | array(depth + 1)
|
||||
("e >> string)
|
||||
| (&object_begin >> object(depth + 1))
|
||||
| (&array_begin >> array(depth + 1))
|
||||
| number
|
||||
| lit_true
|
||||
| lit_false
|
||||
| lit_null
|
||||
,"value"
|
||||
};
|
||||
|
||||
|
@ -198,11 +204,11 @@ ircd::json::input
|
|||
|
||||
rule<enum json::type> type_strict
|
||||
{
|
||||
(omit[string] >> attr(json::STRING)) |
|
||||
(omit[object(0)] >> attr(json::OBJECT)) |
|
||||
(omit[array(0)] >> attr(json::ARRAY)) |
|
||||
(omit[number] >> attr(json::NUMBER)) |
|
||||
(omit[literal] >> attr(json::LITERAL))
|
||||
(omit["e >> string] >> attr(json::STRING)) |
|
||||
(omit[&object_begin >> object(0)] >> attr(json::OBJECT)) |
|
||||
(omit[&array_begin >> array(0)] >> attr(json::ARRAY)) |
|
||||
(omit[number] >> attr(json::NUMBER)) |
|
||||
(omit[literal] >> attr(json::LITERAL))
|
||||
,"type"
|
||||
};
|
||||
|
||||
|
@ -210,14 +216,14 @@ ircd::json::input
|
|||
:input::base_type{rule<>{}} // required by spirit
|
||||
{
|
||||
// synthesized repropagation of recursive rules
|
||||
value %= string
|
||||
| number
|
||||
| lit_true
|
||||
| lit_false
|
||||
| lit_null
|
||||
| object(depth + 1)
|
||||
| array(depth + 1)
|
||||
;
|
||||
value %= ("e >> string)
|
||||
| (&object_begin >> object(depth + 1))
|
||||
| (&array_begin >> array(depth + 1))
|
||||
| number
|
||||
| lit_true
|
||||
| lit_false
|
||||
| lit_null
|
||||
;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue