summaryrefslogtreecommitdiff
path: root/Zend/zend_operators.h
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2017-12-04 17:17:02 +0300
committerDmitry Stogov <dmitry@zend.com>2017-12-04 17:17:02 +0300
commit74c84cd7f0a3a6a5948d633e713b768dd1776cc8 (patch)
treeb3a8746fe703b4989d0a6e8c3ef9ed624dfe3068 /Zend/zend_operators.h
parent7de517a1910b7e8d6b8f3a755e2cc125a6fa0a5c (diff)
downloadphp-git-74c84cd7f0a3a6a5948d633e713b768dd1776cc8.tar.gz
Use zend_string_equal*() API for zend_string equality check instead of direct memcmp() usage.
Diffstat (limited to 'Zend/zend_operators.h')
-rw-r--r--Zend/zend_operators.h35
1 files changed, 13 insertions, 22 deletions
diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h
index 50e1e2dd58..a21727f7ab 100644
--- a/Zend/zend_operators.h
+++ b/Zend/zend_operators.h
@@ -721,6 +721,17 @@ static zend_always_inline int fast_div_function(zval *result, zval *op1, zval *o
return div_function(result, op1, op2);
}
+static zend_always_inline int zend_fast_equal_strings(zend_string *s1, zend_string *s2)
+{
+ if (s1 == s2) {
+ return 1;
+ } else if (ZSTR_VAL(s1)[0] > '9' || ZSTR_VAL(s2)[0] > '9') {
+ return zend_string_equal_content(s1, s2);
+ } else {
+ return zendi_smart_strcmp(s1, s2) == 0;
+ }
+}
+
static zend_always_inline int fast_equal_check_function(zval *op1, zval *op2)
{
zval result;
@@ -738,17 +749,7 @@ static zend_always_inline int fast_equal_check_function(zval *op1, zval *op2)
}
} else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) {
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(Z_STR_P(op1), Z_STR_P(op2)) == 0;
- }
+ return zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2));
}
}
compare_function(&result, op1, op2);
@@ -769,17 +770,7 @@ 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(Z_STR_P(op1), Z_STR_P(op2)) == 0;
- }
+ return zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2));
}
compare_function(&result, op1, op2);
return Z_LVAL(result) == 0;