Skip to content

Commit 034fe44

Browse files
committed
Zend/Optimizer/dfa_pass.c: refactor zend_dfa_optimize_calls()
This function is only called within dfa_pass.c, thus make it static Return a uint32_t as the value can never be negative Add some const qualifiers Minor CS adjustment to make if condition easier to read
1 parent 67cbe09 commit 034fe44

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

Zend/Optimizer/dfa_pass.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -398,22 +398,22 @@ static bool variable_defined_or_used_in_range(zend_ssa *ssa, int var, int start,
398398
return false;
399399
}
400400

401-
int zend_dfa_optimize_calls(zend_op_array *op_array, zend_ssa *ssa)
401+
static uint32_t zend_dfa_optimize_calls(zend_op_array *op_array, zend_ssa *ssa)
402402
{
403-
zend_func_info *func_info = ZEND_FUNC_INFO(op_array);
404-
int removed_ops = 0;
403+
const zend_func_info *func_info = ZEND_FUNC_INFO(op_array);
404+
uint32_t removed_ops = 0;
405405

406406
if (func_info->callee_info) {
407-
zend_call_info *call_info = func_info->callee_info;
407+
const zend_call_info *call_info = func_info->callee_info;
408408

409409
do {
410410
zend_op *op = call_info->caller_init_opline;
411411

412-
if ((op->opcode == ZEND_FRAMELESS_ICALL_2
413-
|| (op->opcode == ZEND_FRAMELESS_ICALL_3 && (op + 1)->op1_type == IS_CONST))
414-
&& call_info->callee_func
415-
&& zend_string_equals_literal_ci(call_info->callee_func->common.function_name, "in_array")) {
416-
412+
if (
413+
(op->opcode == ZEND_FRAMELESS_ICALL_2 || (op->opcode == ZEND_FRAMELESS_ICALL_3 && (op + 1)->op1_type == IS_CONST))
414+
&& call_info->callee_func
415+
&& zend_string_equals_literal_ci(call_info->callee_func->common.function_name, "in_array")
416+
) {
417417
bool strict = false;
418418
bool has_opdata = op->opcode == ZEND_FRAMELESS_ICALL_3;
419419
ZEND_ASSERT(!call_info->is_prototype);
@@ -428,7 +428,7 @@ int zend_dfa_optimize_calls(zend_op_array *op_array, zend_ssa *ssa)
428428
&& Z_TYPE_P(CT_CONSTANT_EX(op_array, op->op2.constant)) == IS_ARRAY) {
429429
bool ok = true;
430430

431-
HashTable *src = Z_ARRVAL_P(CT_CONSTANT_EX(op_array, op->op2.constant));
431+
const HashTable *src = Z_ARRVAL_P(CT_CONSTANT_EX(op_array, op->op2.constant));
432432
HashTable *dst;
433433
zval *val, tmp;
434434
zend_ulong idx;

0 commit comments

Comments
 (0)