Skip to content

Commit 337fbd6

Browse files
committed
Zend/Optimizer: change copy parameter type from int to bool in zend_optimizer_get_persistent_constant
1 parent e99df67 commit 337fbd6

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

Zend/Optimizer/block_pass.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#include "zend_dump.h"
3131

3232
/* Checks if a constant (like "true") may be replaced by its value */
33-
bool zend_optimizer_get_persistent_constant(zend_string *name, zval *result, int copy)
33+
bool zend_optimizer_get_persistent_constant(zend_string *name, zval *result, bool copy)
3434
{
3535
zend_constant *c = zend_hash_find_ptr(EG(zend_constants), name);
3636
if (c) {
@@ -371,7 +371,7 @@ static void zend_optimize_block(zend_basic_block *block, zend_op_array *op_array
371371
}
372372
} else if(flen == sizeof("constant")-1 && zend_binary_strcasecmp(fname, flen, "constant", sizeof("constant")-1) == 0) {
373373
zval c;
374-
if (zend_optimizer_get_persistent_constant(Z_STR_P(arg), &c, 1 ELS_CC)) {
374+
if (zend_optimizer_get_persistent_constant(Z_STR_P(arg), &c, true ELS_CC)) {
375375
literal_dtor(arg);
376376
MAKE_NOP(sv);
377377
MAKE_NOP(fcall);

Zend/Optimizer/pass1.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ void zend_optimizer_pass1(zend_op_array *op_array, zend_optimizer_ctx *ctx)
149149
if (opline->op2_type == IS_CONST &&
150150
Z_TYPE(ZEND_OP2_LITERAL(opline)) == IS_STRING) {
151151
/* substitute persistent constants */
152-
if (!zend_optimizer_get_persistent_constant(Z_STR(ZEND_OP2_LITERAL(opline)), &result, 1)) {
152+
if (!zend_optimizer_get_persistent_constant(Z_STR(ZEND_OP2_LITERAL(opline)), &result, true)) {
153153
if (!ctx->constants || !zend_optimizer_get_collected_constant(ctx->constants, &ZEND_OP2_LITERAL(opline), &result)) {
154154
break;
155155
}
@@ -171,7 +171,7 @@ void zend_optimizer_pass1(zend_op_array *op_array, zend_optimizer_ctx *ctx)
171171
if (Z_TYPE_P(c) == IS_CONSTANT_AST) {
172172
zend_ast *ast = Z_ASTVAL_P(c);
173173
if (ast->kind != ZEND_AST_CONSTANT
174-
|| !zend_optimizer_get_persistent_constant(zend_ast_get_constant_name(ast), &result, 1)
174+
|| !zend_optimizer_get_persistent_constant(zend_ast_get_constant_name(ast), &result, true)
175175
|| Z_TYPE(result) == IS_CONSTANT_AST) {
176176
break;
177177
}
@@ -271,7 +271,7 @@ void zend_optimizer_pass1(zend_op_array *op_array, zend_optimizer_ctx *ctx)
271271
}
272272
break;
273273
case ZEND_DEFINED:
274-
if (!zend_optimizer_get_persistent_constant(Z_STR(ZEND_OP1_LITERAL(opline)), &result, 0)) {
274+
if (!zend_optimizer_get_persistent_constant(Z_STR(ZEND_OP1_LITERAL(opline)), &result, false)) {
275275
break;
276276
}
277277
ZVAL_TRUE(&result);

Zend/Optimizer/zend_optimizer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ zend_result zend_optimizer_eval_special_func_call(
145145
return FAILURE;
146146
}
147147
if (zend_string_equals_literal(name, "constant")) {
148-
return zend_optimizer_get_persistent_constant(arg, result, 1) ? SUCCESS : FAILURE;
148+
return zend_optimizer_get_persistent_constant(arg, result, true) ? SUCCESS : FAILURE;
149149
}
150150
if (zend_string_equals_literal(name, "dirname")) {
151151
if (!IS_ABSOLUTE_PATH(ZSTR_VAL(arg), ZSTR_LEN(arg))) {

Zend/Optimizer/zend_optimizer_internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ static inline bool zend_optimizer_is_loop_var_free(const zend_op *opline) {
8080

8181
void zend_optimizer_convert_to_free_op1(const zend_op_array *op_array, zend_op *opline);
8282
uint32_t zend_optimizer_add_literal(zend_op_array *op_array, const zval *zv);
83-
bool zend_optimizer_get_persistent_constant(zend_string *name, zval *result, int copy);
83+
bool zend_optimizer_get_persistent_constant(zend_string *name, zval *result, bool copy);
8484
void zend_optimizer_collect_constant(zend_optimizer_ctx *ctx, const zval *name, zval* value);
8585
bool zend_optimizer_get_collected_constant(const HashTable *constants, const zval *name, zval* value);
8686
zend_result zend_optimizer_eval_binary_op(zval *result, uint8_t opcode, zval *op1, zval *op2);

0 commit comments

Comments
 (0)