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:
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
|
// 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)
|
("e >> 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["e >> 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 %= ("e >> 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
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue