Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,8 @@ PHP 8.6 UPGRADE NOTES

- JSON:
. Improve performance of encoding arrays and objects.
. Improved performance of indentation generation in json_encode()
when using PHP_JSON_PRETTY_PRINT.

- Standard:
. Improved performance of array_fill_keys().
Expand Down
6 changes: 4 additions & 2 deletions ext/json/json_encoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@ static inline void php_json_pretty_print_char(smart_str *buf, int options, char
static inline void php_json_pretty_print_indent(smart_str *buf, int options, const php_json_encoder *encoder) /* {{{ */
{
if (options & PHP_JSON_PRETTY_PRINT) {
for (int i = 0; i < encoder->depth; ++i) {
smart_str_appendl(buf, " ", 4);
size_t remaining = (size_t) encoder->depth * 4;
if (remaining) {
char *dst = smart_str_extend(buf, remaining);
memset(dst, ' ', remaining);
}
}
}
Expand Down
Loading