summaryrefslogtreecommitdiff
path: root/ext/json
Commit message (Collapse)AuthorAgeFilesLines
* 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.
* 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.
* Add the last missing SKIPIFFabien Villepinte2019-09-041-0/+2
|
* Bump PHP_JSON_VERSION to PHP_VERSIONPeter Kokot2019-07-242-2/+3
| | | | Closes GH-4459
* 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.
* Normalize comments in *nix build system m4 filesPeter Kokot2019-05-121-2/+0
| | | | | | | | | Normalization include: - Use dnl for everything that can be ommitted when configure is built in favor of the shell comment character # which is visible in the output. - Line length normalized to 80 columns - Dots for most of the one line sentences - Macro definitions include similar pattern header comments now
* Adds json_encode test for unpacked arraysJury2019-04-291-0/+16
|
* Merge branch 'PHP-7.3' into PHP-7.4Nikita Popov2019-04-232-2/+35
|\
| * Merge branch 'PHP-7.2' into PHP-7.3Nikita Popov2019-04-232-2/+35
| |\
| | * Fixed bug #77843Nikita Popov2019-04-232-2/+35
| | |
| | * Sync leading and final newlines in *.phpt sectionsPeter Kokot2018-10-155-6/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds missing newlines, trims multiple redundant final newlines into a single one, and trims redundant leading newlines in all *.phpt sections. According to POSIX, a line is a sequence of zero or more non-' <newline>' characters plus a terminating '<newline>' character. [1] Files should normally have at least one final newline character. C89 [2] and later standards [3] mention a final newline: "A source file that is not empty shall end in a new-line character, which shall not be immediately preceded by a backslash character." Although it is not mandatory for all files to have a final newline fixed, a more consistent and homogeneous approach brings less of commit differences issues and a better development experience in certain text editors and IDEs. [1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206 [2] https://port70.net/~nsz/c/c89/c89-draft.html#2.1.1.2 [3] https://port70.net/~nsz/c/c99/n1256.html#5.1.1.2
| | * Trim trailing whitespace in *.phptPeter Kokot2018-10-1414-21/+21
| | |
| | * Sync leading and final newlines in source code filesPeter Kokot2018-10-145-5/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds missing newlines, trims multiple redundant final newlines into a single one, and trims redundant leading newlines. According to POSIX, a line is a sequence of zero or more non-' <newline>' characters plus a terminating '<newline>' character. [1] Files should normally have at least one final newline character. C89 [2] and later standards [3] mention a final newline: "A source file that is not empty shall end in a new-line character, which shall not be immediately preceded by a backslash character." Although it is not mandatory for all files to have a final newline fixed, a more consistent and homogeneous approach brings less of commit differences issues and a better development experience in certain text editors and IDEs. [1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206 [2] https://port70.net/~nsz/c/c89/c89-draft.html#2.1.1.2 [3] https://port70.net/~nsz/c/c99/n1256.html#5.1.1.2
| | * Trim trailing whitespace in source code filesPeter Kokot2018-10-131-1/+1
| | |
| | * year++Xinchen Hui2018-01-0210-10/+10
| | |
| * | Sync leading and final newlines in *.phpt sectionsPeter Kokot2018-10-155-6/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds missing newlines, trims multiple redundant final newlines into a single one, and trims redundant leading newlines in all *.phpt sections. According to POSIX, a line is a sequence of zero or more non-' <newline>' characters plus a terminating '<newline>' character. [1] Files should normally have at least one final newline character. C89 [2] and later standards [3] mention a final newline: "A source file that is not empty shall end in a new-line character, which shall not be immediately preceded by a backslash character." Although it is not mandatory for all files to have a final newline fixed, a more consistent and homogeneous approach brings less of commit differences issues and a better development experience in certain text editors and IDEs. [1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206 [2] https://port70.net/~nsz/c/c89/c89-draft.html#2.1.1.2 [3] https://port70.net/~nsz/c/c99/n1256.html#5.1.1.2
| * | Trim trailing whitespace in *.phptPeter Kokot2018-10-1414-21/+21
| | |
| * | Sync leading and final newlines in source code filesPeter Kokot2018-10-145-5/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds missing newlines, trims multiple redundant final newlines into a single one, and trims redundant leading newlines. According to POSIX, a line is a sequence of zero or more non-' <newline>' characters plus a terminating '<newline>' character. [1] Files should normally have at least one final newline character. C89 [2] and later standards [3] mention a final newline: "A source file that is not empty shall end in a new-line character, which shall not be immediately preceded by a backslash character." Although it is not mandatory for all files to have a final newline fixed, a more consistent and homogeneous approach brings less of commit differences issues and a better development experience in certain text editors and IDEs. [1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206 [2] https://port70.net/~nsz/c/c89/c89-draft.html#2.1.1.2 [3] https://port70.net/~nsz/c/c99/n1256.html#5.1.1.2
| * | Trim trailing whitespace in source code filesPeter Kokot2018-10-131-1/+1
| | |
* | | 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.
* | | Optimization for ASCII dataDmitry Stogov2019-03-181-73/+68
| | |
* | | Remove outdated README for ext/jsonPeter Kokot2019-03-171-16/+0
| | | | | | | | | | | | | | | | | | The php manual already includes introduction to the JSON extension. The re2c and bison version required to build parser and lexer files have changed so to move this info on a central place this removes the README.
* | | Remove function_table var from the callerc9s2019-03-111-1/+1
| | | | | | | | | | | | | | | function_table var is not used in call_user_function macro anymore hence replace the usage with NULL
* | | Add AS_HELP_STRING to *nix build configure optionsPeter Kokot2019-03-071-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | The Autoconf's default AS_HELP_STRING macro can properly format help strings [1] so watching out if columns are aligned manually is not anymore. [1] https://www.gnu.org/software/autoconf/manual/autoconf.html#Pretty-Help-Strings
* | | More zpp error/variation test removalsNikita Popov2019-03-071-28/+0
| | |
* | | Remove obsolescent AC_HEADER_STDC and memcpy checkPeter Kokot2019-03-011-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Autoconf 2.59d (released in 2006) [1] started promoting several macros as not relevant for newer systems anymore, including the `AC_HEADER_STDC`. This macro checks if given system has C89 compliant header files such as `<string.h>`, `<stdlib.h>`, `<stdarg.h>`, `<float.h>`,... and defines the `STDC_HEADERS` symbol [2]. Case is that current systems should be well supported with at least C89 standard headers [3]. Given headers are still additionally checked with the `AC_PROG_CC` macro, yet not needed anyway. Additionally, the HAVE_MEMCPY check has been removed. The memcpy function is standardized by C89 and later. Refs: [1] http://git.savannah.gnu.org/cgit/autoconf.git/tree/NEWS [2] https://www.gnu.org/software/autoconf/manual/autoconf-2.69/autoconf.html [3] https://port70.net/~nsz/c/c89/c89-draft.html#4.1.2
* | | Remove local variablesPeter Kokot2019-02-033-27/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch removes the so called local variables defined per file basis for certain editors to properly show tab width, and similar settings. These are mainly used by Vim and Emacs editors yet with recent changes the once working definitions don't work anymore in Vim without custom plugins or additional configuration. Neither are these settings synced across the PHP code base. A simpler and better approach is EditorConfig and fixing code using some code style fixing tools in the future instead. This patch also removes the so called modelines for Vim. Modelines allow Vim editor specifically to set some editor configuration such as syntax highlighting, indentation style and tab width to be set in the first line or the last 5 lines per file basis. Since the php test files have syntax highlighting already set in most editors properly and EditorConfig takes care of the indentation settings, this patch removes these as well for the Vim 6.0 and newer versions. With the removal of local variables for certain editors such as Emacs and Vim, the footer is also probably not needed anymore when creating extensions using ext_skel.php script. Additionally, Vim modelines for setting php syntax and some editor settings has been removed from some *.phpt files. All these are mostly not relevant for phpt files neither work properly in the middle of the file.
* | | Remove yearly range from copyright noticeZeev Suraski2019-01-308-8/+8
| | |
* | | Remove lexer files generated by RE2CPeter Kokot2018-11-112-1669/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch removes generated lexer files by re2c during the build process so they are not tracked by Git yet can be still shipped when PHP is released. The genfiles script additionally provides generation of these lexer files when creating a release of the PHP source code. The genfiles script refactorings: - added file header - echoing steps instead of comments - cleaning only lines starting with `#line` - eval removed in favor of direct executed commands - the debug mode `set -x` removed - script can be called from any path - improved comments
* | | Remove ext/json parser files generated by bisonPeter Kokot2018-10-243-2066/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The parser files for ext/json are generated by bison from the *.y file. Parser files in Zend and sapi/phpdbg already follow such approach of these files being ignored from tracking in the Git repository and they are shipped via the release packages later on. This way the end users still don't need to have bison dependency installed to install PHP. The genfiles script was refactored to generate the ext/json parser and lexer files.
* | | Sync leading and final newlines in *.phpt sectionsPeter Kokot2018-10-155-6/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds missing newlines, trims multiple redundant final newlines into a single one, and trims redundant leading newlines in all *.phpt sections. According to POSIX, a line is a sequence of zero or more non-' <newline>' characters plus a terminating '<newline>' character. [1] Files should normally have at least one final newline character. C89 [2] and later standards [3] mention a final newline: "A source file that is not empty shall end in a new-line character, which shall not be immediately preceded by a backslash character." Although it is not mandatory for all files to have a final newline fixed, a more consistent and homogeneous approach brings less of commit differences issues and a better development experience in certain text editors and IDEs. [1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206 [2] https://port70.net/~nsz/c/c89/c89-draft.html#2.1.1.2 [3] https://port70.net/~nsz/c/c99/n1256.html#5.1.1.2
* | | Trim trailing whitespace in testsGabriel Caruso2018-10-1414-21/+21
| | |
* | | Sync leading and final newlines in source code filesPeter Kokot2018-10-145-5/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds missing newlines, trims multiple redundant final newlines into a single one, and trims redundant leading newlines. According to POSIX, a line is a sequence of zero or more non-' <newline>' characters plus a terminating '<newline>' character. [1] Files should normally have at least one final newline character. C89 [2] and later standards [3] mention a final newline: "A source file that is not empty shall end in a new-line character, which shall not be immediately preceded by a backslash character." Although it is not mandatory for all files to have a final newline fixed, a more consistent and homogeneous approach brings less of commit differences issues and a better development experience in certain text editors and IDEs. [1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206 [2] https://port70.net/~nsz/c/c89/c89-draft.html#2.1.1.2 [3] https://port70.net/~nsz/c/c99/n1256.html#5.1.1.2
* | | Trim trailing whitespace in source code filesPeter Kokot2018-10-131-1/+1
| | |
* | | Introduce get_properties_for() handlerNikita Popov2018-10-101-2/+7
|/ / | | | | | | | | This handler allows getting the object properties for a particular purpose, such as array casting, serialization, etc.
* | Sync with e0fe6674Anatol Belski2018-08-131-1/+1
| |
* | Fix bug #76030 RE2C_FLAGS rarely honouredCristian Rodríguez2018-08-121-1/+1
| | | | | | | | | | | | | | | | | | Since PHP 5.3 the default lexer generator is RE2C. On Unix-alike build systems there is also optional configure option --enable-re2c-cgoto which enables optimized conditional jumps using non-standard computed goto extension. It is available since RE2C 0.10.3 so it's well covered by RE2C versions PHP uses. This patch syncs usage of -g option accross the PHP Unix-alike build system.
* | Make more tests run on 64bit plataformsGabriel Caruso2018-07-301-2/+1
| |
* | Regenerate scanners using re2c version >= 1.0.0 (newer version, at least, ↵Dmitry Stogov2018-07-252-45/+41
| | | | | | | | produce less code)
* | Remove unused Git attributes identPeter Kokot2018-07-252-4/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The $Id$ keywords were used in Subversion where they can be substituted with filename, last revision number change, last changed date, and last user who changed it. In Git this functionality is different and can be done with Git attribute ident. These need to be defined manually for each file in the .gitattributes file and are afterwards replaced with 40-character hexadecimal blob object name which is based only on the particular file contents. This patch simplifies handling of $Id$ keywords by removing them since they are not used anymore.
* | Revert "Rename _zval_dtor_func to _ref_dtor_func"Xinchen Hui2018-07-062-768/+718
| | | | | | | | This reverts commit a362ae6b12419369c5cbdbb4e924915f9b196ef6.
* | Rename _zval_dtor_func to _ref_dtor_funcXinchen Hui2018-07-062-718/+768
| |
* | Use zval_ptr_dtor_nogc() in JSON parser (it can't produce circular data ↵Dmitry Stogov2018-07-052-26/+26
| | | | | | | | structures)
* | Bump PHP_JSON_VERSION to 1.7.0Jakub Zelenka2018-06-141-1/+1
| |
* | php_json_escape_string() optimizationDmitry Stogov2018-06-131-35/+60
| |
* | Removed useless zval_ptr_dtor()Dmitry Stogov2018-05-291-1/+1
| |
* | Use zend_string_release_ex() instread of zend_string_release() in places, ↵Dmitry Stogov2018-05-283-12/+12
| | | | | | | | where we sure about string persistence.
* | Bit test optimizationDmitry Stogov2018-05-081-1/+1
| |
* | Bit check micro-optimizationDmitry Stogov2018-04-281-1/+1
| |
* | Use int instead of long in protosGabriel Caruso2018-02-231-1/+1
| |