summaryrefslogtreecommitdiff
path: root/Zend/zend_operators.h
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2014-12-27 11:11:40 +0300
committerDmitry Stogov <dmitry@zend.com>2014-12-27 11:11:40 +0300
commit107ae86ca6baf2b79d8ddb32b54676a28269ba1f (patch)
tree9b5e75a7405c70801665789d7344559501696bc1 /Zend/zend_operators.h
parent37466b03686d234f38fc0ec4e0742cbf8dfb5e27 (diff)
downloadphp-git-107ae86ca6baf2b79d8ddb32b54676a28269ba1f.tar.gz
Introduce specialized functions to compare with integer and string, to eliminate repeatable checks on each loop iteration in in_array() function.
Diffstat (limited to 'Zend/zend_operators.h')
-rw-r--r--Zend/zend_operators.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h
index 1426fe919a..20f8ccd32c 100644
--- a/Zend/zend_operators.h
+++ b/Zend/zend_operators.h
@@ -913,6 +913,36 @@ static zend_always_inline int fast_equal_check_function(zval *op1, zval *op2)
return Z_LVAL(result) == 0;
}
+static zend_always_inline int fast_equal_check_long(zval *op1, zval *op2)
+{
+ zval result;
+ if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) {
+ return Z_LVAL_P(op1) == Z_LVAL_P(op2);
+ }
+ compare_function(&result, op1, op2);
+ return Z_LVAL(result) == 0;
+}
+
+static zend_always_inline int fast_equal_check_string(zval *op1, zval *op2)
+{
+ zval result;
+ if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) {
+ if (Z_STR_P(op1) == Z_STR_P(op2)) {
+ return 1;
+ } else if (Z_STRVAL_P(op1)[0] > '9' || Z_STRVAL_P(op2)[0] > '9') {
+ if (Z_STRLEN_P(op1) != Z_STRLEN_P(op2)) {
+ return 0;
+ } else {
+ return memcmp(Z_STRVAL_P(op1), Z_STRVAL_P(op2), Z_STRLEN_P(op1)) == 0;
+ }
+ } else {
+ return zendi_smart_strcmp(op1, op2) == 0;
+ }
+ }
+ compare_function(&result, op1, op2);
+ return Z_LVAL(result) == 0;
+}
+
static zend_always_inline void fast_equal_function(zval *result, zval *op1, zval *op2)
{
if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) {