summaryrefslogtreecommitdiff
path: root/Zend
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2018-09-27 13:11:48 +0300
committerDmitry Stogov <dmitry@zend.com>2018-09-27 13:11:48 +0300
commitc1706980c01353072e760c843846d12ea68ca8b1 (patch)
tree8635eb28fbfb49f1217626f08628577d3bbe42da /Zend
parent390b74ee34ac567cab7d6b07b130a16504bbc43c (diff)
downloadphp-git-c1706980c01353072e760c843846d12ea68ca8b1.tar.gz
Remove dead code (only IS_ARRAY may relive zendi_convert_scalar_to_number()), and micro-optimization.
Diffstat (limited to 'Zend')
-rw-r--r--Zend/zend_operators.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c
index 2081338a01..71663ae31c 100644
--- a/Zend/zend_operators.c
+++ b/Zend/zend_operators.c
@@ -2129,15 +2129,15 @@ ZEND_API int ZEND_FASTCALL compare_function(zval *result, zval *op1, zval *op2)
}
}
if (!converted) {
- if (Z_TYPE_P(op1) == IS_NULL || Z_TYPE_P(op1) == IS_FALSE) {
+ if (Z_TYPE_P(op1) < IS_TRUE) {
ZVAL_LONG(result, zval_is_true(op2) ? -1 : 0);
return SUCCESS;
- } else if (Z_TYPE_P(op2) == IS_NULL || Z_TYPE_P(op2) == IS_FALSE) {
- ZVAL_LONG(result, zval_is_true(op1) ? 1 : 0);
- return SUCCESS;
} else if (Z_TYPE_P(op1) == IS_TRUE) {
ZVAL_LONG(result, zval_is_true(op2) ? 0 : 1);
return SUCCESS;
+ } else if (Z_TYPE_P(op2) < IS_TRUE) {
+ ZVAL_LONG(result, zval_is_true(op1) ? 1 : 0);
+ return SUCCESS;
} else if (Z_TYPE_P(op2) == IS_TRUE) {
ZVAL_LONG(result, zval_is_true(op1) ? 0 : -1);
return SUCCESS;
@@ -2158,14 +2158,12 @@ ZEND_API int ZEND_FASTCALL compare_function(zval *result, zval *op1, zval *op2)
} else if (Z_TYPE_P(op2)==IS_ARRAY) {
ZVAL_LONG(result, -1);
return SUCCESS;
- } else if (Z_TYPE_P(op1)==IS_OBJECT) {
- ZVAL_LONG(result, 1);
- return SUCCESS;
- } else if (Z_TYPE_P(op2)==IS_OBJECT) {
- ZVAL_LONG(result, -1);
- return SUCCESS;
} else {
- ZVAL_LONG(result, 0);
+ ZEND_ASSERT(0);
+ zend_throw_error(NULL, "Unsupported operand types");
+ if (result != op1) {
+ ZVAL_UNDEF(result);
+ }
return FAILURE;
}
}