summaryrefslogtreecommitdiff
path: root/ext/standard/array.c
diff options
context:
space:
mode:
authorGabriel Caruso <carusogabriel34@gmail.com>2018-08-19 01:32:00 -0300
committerPeter Kokot <peterkokot@gmail.com>2018-12-03 01:22:14 +0100
commitcdd8368d6f3f000a2e30a6be9976c5539f10fe85 (patch)
tree8f680d0c1fb552fdcbdbf3d49427c811fa789bf9 /ext/standard/array.c
parent6c16f9b69c1951392d5d0ac89d3fbd2b318af118 (diff)
downloadphp-git-cdd8368d6f3f000a2e30a6be9976c5539f10fe85.tar.gz
Clean up unnecessary ternary expressions and simplify some returns
- Simplify conditions - Use ZEND_HASH_APPLY_* instead of hard-coded booleans - Use ZEND_NORMALIZE_BOOL - Drop sign in favor of ZEND_NORMALIZE_BOOL
Diffstat (limited to 'ext/standard/array.c')
-rw-r--r--ext/standard/array.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/ext/standard/array.c b/ext/standard/array.c
index 3d1b59aa64..a6dda1ce18 100644
--- a/ext/standard/array.c
+++ b/ext/standard/array.c
@@ -170,7 +170,7 @@ static int php_array_key_compare(const void *a, const void *b) /* {{{ */
}
}
}
- return l1 > l2 ? 1 : (l1 < l2 ? -1 : 0);
+ return ZEND_NORMALIZE_BOOL(l1 > l2);
}
/* }}} */
@@ -978,7 +978,7 @@ static int php_array_user_compare(const void *a, const void *b) /* {{{ */
zval_ptr_dtor(&retval);
zval_ptr_dtor(&args[1]);
zval_ptr_dtor(&args[0]);
- return ret < 0 ? -1 : ret > 0 ? 1 : 0;
+ return ZEND_NORMALIZE_BOOL(ret);
} else {
zval_ptr_dtor(&args[1]);
zval_ptr_dtor(&args[0]);
@@ -1101,7 +1101,7 @@ static int php_array_user_key_compare(const void *a, const void *b) /* {{{ */
zval_ptr_dtor(&args[0]);
zval_ptr_dtor(&args[1]);
- return result < 0 ? -1 : result > 0 ? 1 : 0;
+ return ZEND_NORMALIZE_BOOL(result);
}
/* }}} */
@@ -4583,7 +4583,7 @@ static int zval_user_compare(zval *a, zval *b) /* {{{ */
if (zend_call_function(&BG(user_compare_fci), &BG(user_compare_fci_cache)) == SUCCESS && Z_TYPE(retval) != IS_UNDEF) {
zend_long ret = zval_get_long(&retval);
zval_ptr_dtor(&retval);
- return ret < 0 ? -1 : ret > 0 ? 1 : 0;
+ return ZEND_NORMALIZE_BOOL(ret);
} else {
return 0;
}