Skip to content

Commit 3c8b68e

Browse files
committed
cheaper pos compute
1 parent e3baa23 commit 3c8b68e

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
@@ -561,10 +561,9 @@ zend_result php_json_escape_string(
561561
break;
562562
}
563563

564-
int shift = zend_ulong_nlz(mask) - 16 - (SIZEOF_ZEND_LONG == 8 ? 32 : 0); /* skips over everything */
565564
smart_str_appendl(buf, s, pos);
566565
s += pos;
567-
pos = shift;
566+
const char *s_backup = s;
568567

569568
do {
570569
/* Note that we shift the input forward, so we have to shift the mask as well,
@@ -580,6 +579,8 @@ zend_result php_json_escape_string(
580579
bool handled = php_json_printable_ascii_escape(buf, us, options);
581580
ZEND_ASSERT(handled == true);
582581
} while (mask != 0);
582+
583+
pos = 16 - (s - s_backup);
583584
} else {
584585
if (max_shift < 16) {
585586
pos += max_shift;

0 commit comments

Comments
 (0)