8000 zend_compile: Optimize `sprintf()` into a rope by TimWolla · Pull Request #14546 · php/php-src · GitHub
[go: up one dir, main page]

Skip to content

zend_compile: Optimize sprintf() into a rope #14546

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jun 13, 2024
Prev Previous commit
Next Next commit
zend_compile: Use clearer parameter names for `zend_compile_rope_fina…
…lize()`
  • Loading branch information
TimWolla committed Jun 12, 2024
commit 72f9b2434322d1e4053d6e8d2883c8355cb366a3
10 changes: 5 additions & 5 deletions Zend/zend_compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -10188,9 +10188,9 @@ static zend_op *zend_compile_rope_add(znode *result, uint32_t num, znode *elem_n
}
/* }}} */

static void zend_compile_rope_finalize(znode *result, uint32_t j, zend_op *init_opline, zend_op *opline)
static void zend_compile_rope_finalize(znode *result, uint32_t rope_elements, zend_op *init_opline, zend_op *opline)
{
if (j == 1) {
if (rope_elements == 1) {
if (opline->op2_type == IS_CONST) {
GET_NODE(result, opline->op2);
MAKE_NOP(opline);
Expand All @@ -10202,7 +10202,7 @@ static void zend_compile_rope_finalize(znode *result, uint32_t j, zend_op *init_
SET_UNUSED(opline->op2);
zend_make_tmp_result(result, opline);
}
} else if (j == 2) {
} else if (rope_elements == 2) {
opline->opcode = ZEND_FAST_CONCAT;
opline->extended_value = 0;
opline->op1_type = init_opline->op2_type;
Expand All @@ -10212,13 +10212,13 @@ static void zend_compile_rope_finalize(znode *result, uint32_t j, zend_op *init_
} else {
uint32_t var;

init_opline->extended_value = j;
init_opline->extended_value = rope_elements;
opline->opcode = ZEND_ROPE_END;
zend_make_tmp_result(result, opline);
var = opline->op1.var = get_temporary_variable();

/* Allocates the necessary number of zval slots to keep the rope */
uint32_t i = ((j * sizeof(zend_string*)) + (sizeof(zval) - 1)) / sizeof(zval);
uint32_t i = ((rope_elements * sizeof(zend_string*)) + (sizeof(zval) - 1)) / sizeof(zval);
while (i > 1) {
get_temporary_variable();
i--;
Expand Down
0