Skip to content

Commit

Permalink
Remove unnecessary convert_to_string_safe macro
Browse files Browse the repository at this point in the history
I'm assuming that the reason this existed was to avoid modifying
an interned string. However, the current code handles this case
fine already.
  • Loading branch information
nikic committed Feb 28, 2019
1 parent 89a7b7c commit 1b998bb
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions ext/opcache/Optimizer/block_pass.c
Expand Up @@ -81,13 +81,6 @@ int zend_optimizer_get_persistent_constant(zend_string *name, zval *result, int
#define VAR_SOURCE(op) Tsource[VAR_NUM(op.var)]
#define SET_VAR_SOURCE(opline) Tsource[VAR_NUM(opline->result.var)] = opline

#define convert_to_string_safe(v) \
if (Z_TYPE_P((v)) == IS_NULL) { \
ZVAL_STRINGL((v), "", 0); \
} else { \
convert_to_string((v)); \
}

static void strip_leading_nops(zend_op_array *op_array, zend_basic_block *b)
{
zend_op *opcodes = op_array->opcodes;
Expand Down Expand Up @@ -311,10 +304,10 @@ static void zend_optimize_block(zend_basic_block *block, zend_op_array *op_array
int l, old_len;

if (Z_TYPE(ZEND_OP1_LITERAL(opline)) != IS_STRING) {
convert_to_string_safe(&ZEND_OP1_LITERAL(opline));
convert_to_string(&ZEND_OP1_LITERAL(opline));
}
if (Z_TYPE(ZEND_OP1_LITERAL(last_op)) != IS_STRING) {
convert_to_string_safe(&ZEND_OP1_LITERAL(last_op));
convert_to_string(&ZEND_OP1_LITERAL(last_op));
}
old_len = Z_STRLEN(ZEND_OP1_LITERAL(last_op));
l = old_len + Z_STRLEN(ZEND_OP1_LITERAL(opline));
Expand Down Expand Up @@ -694,10 +687,10 @@ static void zend_optimize_block(zend_basic_block *block, zend_op_array *op_array
int l, old_len;

if (Z_TYPE(ZEND_OP2_LITERAL(opline)) != IS_STRING) {
convert_to_string_safe(&ZEND_OP2_LITERAL(opline));
convert_to_string(&ZEND_OP2_LITERAL(opline));
}
if (Z_TYPE(ZEND_OP2_LITERAL(src)) != IS_STRING) {
convert_to_string_safe(&ZEND_OP2_LITERAL(src));
convert_to_string(&ZEND_OP2_LITERAL(src));
}

VAR_SOURCE(opline->op1) = NULL;
Expand Down

0 comments on commit 1b998bb

Please sign in to comment.