diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index 7f1b3234acea3..8820c5163c12d 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -58,7 +58,7 @@ static _locale_t current_locale = NULL; #define zend_tolower(c) tolower(c) #endif -#define TYPE_PAIR(t1,t2) (((t1) << 4) | (t2)) +#define TYPE_PAIR(t1,t2) ((unsigned char) (((t1) << 4) | (t2))) #ifdef ZEND_INTRIN_AVX2_NATIVE #define HAVE_BLOCKCONV @@ -2235,127 +2235,133 @@ static int compare_double_to_string(double dval, zend_string *str) /* {{{ */ } /* }}} */ -ZEND_API int ZEND_FASTCALL zend_compare(zval *op1, zval *op2) /* {{{ */ +static int ZEND_FASTCALL zend_compare_fast(zval *op1, zval *op2, bool converted); + +static int ZEND_FASTCALL zend_compare_slow(zval *op1, zval *op2, bool converted) { - int converted = 0; - zval op1_copy, op2_copy; + if (Z_ISREF_P(op1) || Z_ISREF_P(op2)) { + ZVAL_DEREF(op1); + ZVAL_DEREF(op2); + return zend_compare_fast(op1, op2, converted); + } - while (1) { - switch (TYPE_PAIR(Z_TYPE_P(op1), Z_TYPE_P(op2))) { - case TYPE_PAIR(IS_LONG, IS_LONG): - return Z_LVAL_P(op1)>Z_LVAL_P(op2)?1:(Z_LVAL_P(op1)Z_LVAL_P(op2)?1:(Z_LVAL_P(op1) lval2 ? 1 : (lval1 < lval2 ? -1 : 0); }