diff options
Diffstat (limited to 'Zend/zend_compile.c')
-rw-r--r-- | Zend/zend_compile.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index c8199c1c14..776ad6ba9e 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -8549,25 +8549,28 @@ void zend_eval_const_expr(zend_ast **ast_ptr) /* {{{ */ case ZEND_AST_AND: case ZEND_AST_OR: { - int i; - for (i = 0; i <= 1; i++) { - zend_eval_const_expr(&ast->child[i]); - if (ast->child[i]->kind == ZEND_AST_ZVAL) { - if (zend_is_true(zend_ast_get_zval(ast->child[i])) == (ast->kind == ZEND_AST_OR)) { - ZVAL_BOOL(&result, ast->kind == ZEND_AST_OR); - return; - } - } + zend_bool child0_is_true, child1_is_true; + zend_eval_const_expr(&ast->child[0]); + zend_eval_const_expr(&ast->child[1]); + if (ast->child[0]->kind != ZEND_AST_ZVAL) { + return; } - if (ast->child[0]->kind != ZEND_AST_ZVAL || ast->child[1]->kind != ZEND_AST_ZVAL) { + child0_is_true = zend_is_true(zend_ast_get_zval(ast->child[0])); + if (child0_is_true == (ast->kind == ZEND_AST_OR)) { + ZVAL_BOOL(&result, ast->kind == ZEND_AST_OR); + break; + } + + if (ast->child[1]->kind != ZEND_AST_ZVAL) { return; } + child1_is_true = zend_is_true(zend_ast_get_zval(ast->child[1])); if (ast->kind == ZEND_AST_OR) { - ZVAL_BOOL(&result, zend_is_true(zend_ast_get_zval(ast->child[0])) || zend_is_true(zend_ast_get_zval(ast->child[1]))); + ZVAL_BOOL(&result, child0_is_true || child1_is_true); } else { - ZVAL_BOOL(&result, zend_is_true(zend_ast_get_zval(ast->child[0])) && zend_is_true(zend_ast_get_zval(ast->child[1]))); + ZVAL_BOOL(&result, child0_is_true && child1_is_true); } break; } |