summaryrefslogtreecommitdiff
path: root/ext/json/json_parser.y
Commit message (Collapse)AuthorAgeFilesLines
* Inline pair production in json parserNikita Popov2020-11-131-18/+4
| | | | | Having this as a separate production has a noticeable performance impact, and doesn't really make things clearer either.
* Voidify some ZEND_API functionsGeorge Peter Banyard2020-07-091-2/+2
| | | | Closes GH-5805
* Constify char * arguments of APIstwosee2020-06-081-2/+2
| | | | Closes GH-5676.
* Clean up the generation of the parsersAkim Demaille2020-02-011-3/+2
| | | | | | | | | | | | | | | | Prefer '%define api.value.type' to '#define YYSTYPE', so that Bison know the type. Use '%code requires' to declare what is needed to define the api.value.type (that code is output in the generated header before the generated definition of YYSTYPE). Prefer '%define api.prefix' inside the grammar file to '-p' outside, as anyway the functions defined in the file actually use this prefix. Prefer `%param` to both `%parse-param` and `%lex-param`. Closes GH-5138
* Use "%empty" in the parsers, instead of commentsAkim Demaille2020-01-311-2/+3
| | | | | | | | | | The annotation %empty is properly enforced: warnings when it's missing, and errors when it's inappropriate. Support for %empty was introduced in Bison 3.0. Pass -Wempty-rule to Bison. Closes GH-5134
* Merge branch 'PHP-7.4'Nikita Popov2019-10-301-2/+12
|\ | | | | | | | | * PHP-7.4: Optimize creation of empty arrays in json_decode
| * Optimize creation of empty arrays in json_decodeTyson Andre2019-10-301-2/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use the shared empty array from ZVAL_EMPTY_ARRAY For code that created an 10 arrays of 100000 empty arrays (has the same result with `$assoc=true` and `{}`) - This is the worst-case comparison, but I'd expect 0-length arrays to be fairly common in regular data for json_decode - The parser implementation was using function pointers so that third party extension developers could reuse the json parser for their own data structures, etc. (I think). This PR is meant to let those third party extensions continue working without changes. Before this patch: In 0.126 seconds: added 97.99 MiB After this patch: In 0.096 seconds: added 41.99 MiB ```php <?php $json = '[' . str_repeat('[],', 100000) . "null]"; $start_memory = memory_get_usage(); $start_time = microtime(true); $result = []; for ($i = 0; $i < 10; $i++) { $result[] = json_decode($json); } $end_memory = memory_get_usage(); $end_time = microtime(true); // Before this patch: In 0.126 seconds: added 97.99 MiB // After this patch: In 0.096 seconds: added 41.99 MiB printf("In %.3f seconds: added %.2f MiB\n", $end_time - $start_time, ($end_memory - $start_memory)/1000000); // For objects $json = '[' . str_repeat('{},', 100000) . "null]"; $start_memory = memory_get_usage(); $start_time = microtime(true); for ($i = 0; $i < 10; $i++) { $result[] = json_decode($json, true); } $end_memory = memory_get_usage(); $end_time = microtime(true); // Before this patch: In 0.126 seconds: added 97.99 MiB // After this patch: In 0.096 seconds: added 41.99 MiB printf("In %.3f seconds: added %.2f MiB (objects decoded as arrays) \n", $end_time - $start_time, ($end_memory - $start_memory)/1000000); ``` Closes GH-4861.
* | Remove mention of PHP major version in Copyright headersGabriel Caruso2019-09-251-2/+0
| | | | | | | | Closes GH-4732.
* | Merge branch 'PHP-7.4'Nikita Popov2019-09-191-33/+4
|\ \ | |/
| * Clean up JSON parserNikita Popov2019-09-191-33/+4
| | | | | | | | | | | | | | | | | | | | Don't use <value> type for JSON tokens that don't have a value and remove the errlex productions -- we're going to get an unexpected token error anyway, there's no need to handle these explicitly. This also removes the awkward workarounds for the unused value warnings.
* | Merge branch 'PHP-7.4'Nikita Popov2019-06-121-1/+1
|\ \ | |/
| * Use %define api.pure instead of %pure-parserNikita Popov2019-06-121-1/+1
| | | | | | | | | | %pure-parser is deprecated. In our case there is no difference between true & full, as we don't use locations.
* | Merge branch 'PHP-7.4'Peter Kokot2019-03-191-1/+1
|\ \ | |/ | | | | | | * PHP-7.4: Upgrade deprecated directives and use non-posix bison
| * Upgrade deprecated directives and use non-posix bisonPeter Kokot2019-03-191-1/+1
| | | | | | | | | | | | | | | | | | | | With Bison 3.0 some directives are deprecated: - %name-prefix "x" should be %define api.prefix {x} - %error-verbose should be %define parse.error verbose Bison 3.3 also started emiting more warnings and since PHP souce parsers are not POSIX compliant this patch fixes this as pointed out via 495a46aa1dc564656bf919cb49aae48a31ae15f4.
| * Remove yearly range from copyright noticeZeev Suraski2019-01-301-1/+1
| |
* | Refactor zend_object_handlers API to pass zend_object* and zend_string* ↵Dmitry Stogov2019-02-041-3/+1
| | | | | | | | insted of zval(s).
* | Remove year range from copyright noticeZeev Suraski2019-01-301-1/+1
|/
* Use zval_ptr_dtor_nogc() in JSON parser (it can't produce circular data ↵Dmitry Stogov2018-07-051-4/+4
| | | | structures)
* Use zend_string_release_ex() instread of zend_string_release() in places, ↵Dmitry Stogov2018-05-281-3/+3
| | | | where we sure about string persistence.
* year++Xinchen Hui2018-01-021-1/+1
|
* RC manipulation cleanup 2Xinchen Hui2017-11-021-4/+1
|
* Sync json parser defsAnatol Belski2017-09-201-2/+4
|
* Update copyright headers to 2017Sammy Kaye Powers2017-01-021-1/+1
|
* Use empty keys instead of _empty_ in json decodingJakub Zelenka2016-06-201-4/+1
|
* Fix and clean up exporting of json parserJakub Zelenka2016-05-111-3/+8
|
* Use embedded json parser method structureJakub Zelenka2016-05-021-13/+13
|
* Remove json parser depth methods and tidy it upJakub Zelenka2016-04-101-51/+39
|
* Add method hooking support to json parserJakub Zelenka2016-04-101-45/+113
| | | | | | | This commit is just a slight modification (renaming and some small changes) of the patch that has been provided by Andrey Hristov. It adds support for hooking of the json parser operations and allows re-using of modified JSON parsing outside of json ext.
* Happy new year (Update copyright to 2016)Lior Kaplan2016-01-011-1/+1
|
* Use ZSTR_ API to access zend_string elements (this is just renaming without ↵Dmitry Stogov2015-06-301-2/+2
| | | | semantick changes).
* Fix bug #68546 (json_decode cannot access property started with \0)Jakub Zelenka2015-06-211-4/+14
|
* Improve json parser codeJakub Zelenka2015-06-071-17/+80
|
* Tidy up and regenerate json parser with latest bison versionJakub Zelenka2015-05-101-2/+2
|
* Optimized json_parserXinchen Hui2015-05-061-21/+21
| | | | | | 1. use zend_string in key 2. use faster APIs 3. use ZVAL_COPY_VALUE instead of assignment (save u2 copy)
* fix datatype mismatchesAnatol Belski2015-03-251-1/+1
|
* s/PHP Version 5/PHP Version 7/gLior Kaplan2015-03-131-1/+1
| | | | Follow up for d0cb7153
* ZTS cleanupReeze Xia2015-03-081-1/+1
|
* Remove unused destructor in json parserJakub Zelenka2015-02-151-1/+0
|
* fix datatype mismatchesAnatol Belski2015-02-091-1/+1
|
* fix inconsistend dll linkage warnAnatol Belski2015-02-091-0/+5
|
* use size_t for str lengthAnatol Belski2015-02-091-1/+1
|
* Merge branch 'master' into jsondJakub Zelenka2015-01-251-1/+1
| | | | | | Conflicts: ext/json/JSON_parser.c ext/json/json.c
* Use ZVAL_COPY_VALUE for copying parser result to return_valueJakub Zelenka2015-01-011-1/+1
|
* Merge branch 'master' into jsondJakub Zelenka2014-12-271-6/+2
| | | | | | | | | | Conflicts: ext/json/JSON_parser.c ext/json/JSON_parser.h ext/json/config.m4 ext/json/config.w32 ext/json/json.c ext/json/php_json.h
* Fix json object decodingJakub Zelenka2014-12-121-5/+8
|
* Do not copy return_value in parserJakub Zelenka2014-12-071-1/+1
|
* Fix compilation for json scannerJakub Zelenka2014-11-301-1/+2
|
* Fix compilation issues in json_parserJakub Zelenka2014-11-261-9/+9
|
* Implement initial changes for json_parserJakub Zelenka2014-11-231-46/+31
|
* Replace INIT_PZVAL_COPY with ZVAL_DUPJakub Zelenka2014-11-161-1/+1
|