Skip to content

Commit 847497f

Browse files
committed
tweak
1 parent 246b413 commit 847497f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

ext/json/json_encoder.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ static zend_result php_json_encode_array(smart_str *buf, zval *val, int options,
379379
/* }}} */
380380

381381
/* Specialization of smart_str_appendl() to avoid performance loss due to code bloat */
382-
static void php_json_append(smart_str *dest, const char *src, size_t len)
382+
static zend_always_inline void php_json_append(smart_str *dest, const char *src, size_t len)
383383
{
384384
/* smart_str has a minimum size of the input length,
385385
* this avoids generating initial allocation code */
@@ -688,8 +688,8 @@ zend_result php_json_escape_string(
688688
const char *cur = s + pos;
689689
pos = 0;
690690
us = php_next_utf8_char((unsigned char *)cur, len, &pos, &status);
691+
len -= pos;
691692
pos += pos_old;
692-
len -= pos - pos_old;
693693

694694
/* check whether UTF8 character is correct */
695695
if (UNEXPECTED(!us)) {
@@ -807,6 +807,7 @@ zend_result php_json_escape_string(
807807
php_json_append(buf, s, pos);
808808
}
809809

810+
ZEND_ASSERT(buf->s);
810811
smart_str_appendc(buf, '"');
811812

812813
return SUCCESS;

0 commit comments

Comments
 (0)