com php-src: Inline pair production in json parser: ext/json/json_parser.y
| From: | Nikita Popov | Date: | Fri, 13 Nov 2020 13:56:29 +0000 |
| Subject: | com php-src: Inline pair production in json parser: ext/json/json_parser.y | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-114142@lists.php.net to get a copy of this message | ||
Commit: f5be0e5110ff816d2ce168c154cb3575d08e3cad
Author: Nikita Popov <nikita.ppv@gmail.com> Fri, 13 Nov 2020 14:55:26 +0100
Parents: a08a2b48b489572db89940027206020ee714afa5
Branches: PHP-8.0 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=f5be0e5110ff816d2ce168c154cb3575d08e3cad
Log:
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.
Changed paths:
M ext/json/json_parser.y
Diff:
diff --git a/ext/json/json_parser.y b/ext/json/json_parser.y
index 77df0eef6a5..81860400880 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:
'['
{