diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2020-11-13 14:55:26 +0100 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2020-11-13 14:56:29 +0100 |
commit | f5be0e5110ff816d2ce168c154cb3575d08e3cad (patch) | |
tree | ead8cfb1c69573f2c3d041385a62a4ce1bda121d | |
parent | a08a2b48b489572db89940027206020ee714afa5 (diff) | |
download | php-git-f5be0e5110ff816d2ce168c154cb3575d08e3cad.tar.gz |
Inline pair production in json parser
Having this as a separate production has a noticeable performance
impact, and doesn't really make things clearer either.
-rw-r--r-- | ext/json/json_parser.y | 22 |
1 files changed, 4 insertions, 18 deletions
diff --git a/ext/json/json_parser.y b/ext/json/json_parser.y index 77df0eef6a..8186040088 100644 --- a/ext/json/json_parser.y +++ b/ext/json/json_parser.y @@ -47,10 +47,6 @@ int json_yydebug = 1; %union { zval value; - struct { - zend_string *key; - zval val; - } pair; } @@ -66,10 +62,8 @@ int json_yydebug = 1; %type <value> start object key value array %type <value> members member elements element -%type <pair> pair %destructor { zval_ptr_dtor_nogc(&$$); } <value> -%destructor { zend_string_release_ex($$.key, 0); zval_ptr_dtor_nogc(&$$.val); } <pair> %code { static int php_json_yylex(union YYSTYPE *value, php_json_parser *parser); @@ -130,30 +124,22 @@ members: ; member: - pair + key ':' value { parser->methods.object_create(parser, &$$); - if (parser->methods.object_update(parser, &$$, $1.key, &$1.val) == FAILURE) { + if (parser->methods.object_update(parser, &$$, Z_STR($1), &$3) == FAILURE) { YYERROR; } } - | member ',' pair + | member ',' key ':' value { - if (parser->methods.object_update(parser, &$1, $3.key, &$3.val) == FAILURE) { + if (parser->methods.object_update(parser, &$1, Z_STR($3), &$5) == FAILURE) { YYERROR; } ZVAL_COPY_VALUE(&$$, &$1); } ; -pair: - key ':' value - { - $$.key = Z_STR($1); - ZVAL_COPY_VALUE(&$$.val, &$3); - } -; - array: '[' { |