Skip to content

Commit 9ac40b5

Browse files
committed
apply changes from reviews
1 parent a967ff1 commit 9ac40b5

1 file changed

Lines changed: 2 additions & 9 deletions

File tree

ext/json/json_encoder.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,10 @@ static inline void php_json_pretty_print_char(smart_str *buf, int options, char
5454
static inline void php_json_pretty_print_indent(smart_str *buf, int options, const php_json_encoder *encoder) /* {{{ */
5555
{
5656
if (options & PHP_JSON_PRETTY_PRINT) {
57-
static const char spaces[] =
58-
" ";
5957
size_t remaining = (size_t) encoder->depth * 4;
60-
61-
while (remaining >= sizeof(spaces) - 1) {
62-
smart_str_appendl(buf, spaces, sizeof(spaces) - 1);
63-
remaining -= sizeof(spaces) - 1;
64-
}
65-
6658
if (remaining) {
67-
smart_str_appendl(buf, spaces, remaining);
59+
char *dst = smart_str_extend(buf, remaining);
60+
memset(dst, ' ', remaining);
6861
}
6962
}
7063
}

0 commit comments

Comments
 (0)