Skip to content

Commit

Permalink
tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
nielsdos committed Feb 6, 2025
1 parent 246b413 commit 847497f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ext/json/json_encoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ static zend_result php_json_encode_array(smart_str *buf, zval *val, int options,
/* }}} */

/* Specialization of smart_str_appendl() to avoid performance loss due to code bloat */
static void php_json_append(smart_str *dest, const char *src, size_t len)
static zend_always_inline void php_json_append(smart_str *dest, const char *src, size_t len)
{
/* smart_str has a minimum size of the input length,
* this avoids generating initial allocation code */
Expand Down Expand Up @@ -688,8 +688,8 @@ zend_result php_json_escape_string(
const char *cur = s + pos;
pos = 0;
us = php_next_utf8_char((unsigned char *)cur, len, &pos, &status);
len -= pos;
pos += pos_old;
len -= pos - pos_old;

/* check whether UTF8 character is correct */
if (UNEXPECTED(!us)) {
Expand Down Expand Up @@ -807,6 +807,7 @@ zend_result php_json_escape_string(
php_json_append(buf, s, pos);
}

ZEND_ASSERT(buf->s);
smart_str_appendc(buf, '"');

return SUCCESS;
Expand Down

0 comments on commit 847497f

Please # to comment.