Skip to content

Commit fea9b5c

Browse files
committed
Use zend_string_equals_literal() macro
1 parent 53d5420 commit fea9b5c

File tree

1 file changed

+6
-17
lines changed

1 file changed

+6
-17
lines changed

Zend/Optimizer/pass1.c

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,7 @@ void zend_optimizer_pass1(zend_op_array *op_array, zend_optimizer_ctx *ctx)
174174
case ZEND_FETCH_CONSTANT:
175175
if (opline->op2_type == IS_CONST &&
176176
Z_TYPE(ZEND_OP2_LITERAL(opline)) == IS_STRING &&
177-
Z_STRLEN(ZEND_OP2_LITERAL(opline)) == sizeof("__COMPILER_HALT_OFFSET__") - 1 &&
178-
memcmp(Z_STRVAL(ZEND_OP2_LITERAL(opline)), "__COMPILER_HALT_OFFSET__", sizeof("__COMPILER_HALT_OFFSET__") - 1) == 0) {
177+
zend_string_equals_literal(Z_STR(ZEND_OP2_LITERAL(opline)), "__COMPILER_HALT_OFFSET__")) {
179178
/* substitute __COMPILER_HALT_OFFSET__ constant */
180179
zend_execute_data *orig_execute_data = EG(current_execute_data);
181180
zend_execute_data fake_execute_data;
@@ -376,12 +375,8 @@ void zend_optimizer_pass1(zend_op_array *op_array, zend_optimizer_ctx *ctx)
376375
*/
377376
if (!send2_opline &&
378377
Z_TYPE(ZEND_OP1_LITERAL(send1_opline)) == IS_STRING) {
379-
if ((Z_STRLEN(ZEND_OP2_LITERAL(init_opline)) == sizeof("function_exists")-1 &&
380-
!memcmp(Z_STRVAL(ZEND_OP2_LITERAL(init_opline)),
381-
"function_exists", sizeof("function_exists")-1)) ||
382-
(Z_STRLEN(ZEND_OP2_LITERAL(init_opline)) == sizeof("is_callable")-1 &&
383-
!memcmp(Z_STRVAL(ZEND_OP2_LITERAL(init_opline)),
384-
"is_callable", sizeof("is_callable")))) {
378+
if (zend_string_equals_literal(Z_STR(ZEND_OP2_LITERAL(init_opline)), "function_exists") ||
379+
zend_string_equals_literal(Z_STR(ZEND_OP2_LITERAL(init_opline)), "is_callable")) {
385380
zend_internal_function *func;
386381
zend_string *lc_name = zend_string_tolower(
387382
Z_STR(ZEND_OP1_LITERAL(send1_opline)));
@@ -410,9 +405,7 @@ void zend_optimizer_pass1(zend_op_array *op_array, zend_optimizer_ctx *ctx)
410405
}
411406
zend_string_release_ex(lc_name, 0);
412407
break;
413-
} else if (Z_STRLEN(ZEND_OP2_LITERAL(init_opline)) == sizeof("extension_loaded")-1 &&
414-
!memcmp(Z_STRVAL(ZEND_OP2_LITERAL(init_opline)),
415-
"extension_loaded", sizeof("extension_loaded")-1)) {
408+
} else if (zend_string_equals_literal(Z_STR(ZEND_OP2_LITERAL(init_opline)), "extension_loaded")) {
416409
zval t;
417410
zend_string *lc_name = zend_string_tolower(
418411
Z_STR(ZEND_OP1_LITERAL(send1_opline)));
@@ -451,9 +444,7 @@ void zend_optimizer_pass1(zend_op_array *op_array, zend_optimizer_ctx *ctx)
451444
zend_optimizer_update_op1_const(op_array, opline, &t);
452445
}
453446
break;
454-
} else if (Z_STRLEN(ZEND_OP2_LITERAL(init_opline)) == sizeof("constant")-1 &&
455-
!memcmp(Z_STRVAL(ZEND_OP2_LITERAL(init_opline)),
456-
"constant", sizeof("constant")-1)) {
447+
} else if (zend_string_equals_literal(Z_STR(ZEND_OP2_LITERAL(init_opline)), "constant")) {
457448
zval t;
458449

459450
if (zend_optimizer_get_persistent_constant(Z_STR(ZEND_OP1_LITERAL(send1_opline)), &t, 1)) {
@@ -472,9 +463,7 @@ void zend_optimizer_pass1(zend_op_array *op_array, zend_optimizer_ctx *ctx)
472463
}
473464
break;
474465
/* dirname(IS_CONST/IS_STRING) -> IS_CONST/IS_STRING */
475-
} else if (Z_STRLEN(ZEND_OP2_LITERAL(init_opline)) == sizeof("dirname")-1 &&
476-
!memcmp(Z_STRVAL(ZEND_OP2_LITERAL(init_opline)),
477-
"dirname", sizeof("dirname") - 1) &&
466+
} else if (zend_string_equals_literal(Z_STR(ZEND_OP2_LITERAL(init_opline)), "dirname") &&
478467
IS_ABSOLUTE_PATH(Z_STRVAL(ZEND_OP1_LITERAL(send1_opline)), Z_STRLEN(ZEND_OP1_LITERAL(send1_opline)))) {
479468
zend_string *dirname = zend_string_init(Z_STRVAL(ZEND_OP1_LITERAL(send1_opline)), Z_STRLEN(ZEND_OP1_LITERAL(send1_opline)), 0);
480469
ZSTR_LEN(dirname) = zend_dirname(ZSTR_VAL(dirname), ZSTR_LEN(dirname));

0 commit comments

Comments
 (0)