mirror of
https://github.com/php/php-src.git
synced 2024-11-27 03:44:07 +08:00
Make zend_hash_sort() return void
This function always succeeds, so remove the success indicator return value.
This commit is contained in:
parent
8ccdb8282e
commit
e86cdce549
@ -2459,7 +2459,7 @@ ZEND_API void zend_hash_bucket_packed_swap(Bucket *p, Bucket *q)
|
||||
q->h = h;
|
||||
}
|
||||
|
||||
ZEND_API int ZEND_FASTCALL zend_hash_sort_ex(HashTable *ht, sort_func_t sort, compare_func_t compar, zend_bool renumber)
|
||||
ZEND_API void ZEND_FASTCALL zend_hash_sort_ex(HashTable *ht, sort_func_t sort, compare_func_t compar, zend_bool renumber)
|
||||
{
|
||||
Bucket *p;
|
||||
uint32_t i, j;
|
||||
@ -2468,7 +2468,7 @@ ZEND_API int ZEND_FASTCALL zend_hash_sort_ex(HashTable *ht, sort_func_t sort, co
|
||||
HT_ASSERT_RC1(ht);
|
||||
|
||||
if (!(ht->nNumOfElements>1) && !(renumber && ht->nNumOfElements>0)) { /* Doesn't require sorting */
|
||||
return SUCCESS;
|
||||
return;
|
||||
}
|
||||
|
||||
if (HT_IS_WITHOUT_HOLES(ht)) {
|
||||
@ -2523,8 +2523,6 @@ ZEND_API int ZEND_FASTCALL zend_hash_sort_ex(HashTable *ht, sort_func_t sort, co
|
||||
zend_hash_rehash(ht);
|
||||
}
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
static zend_always_inline int zend_hash_compare_impl(HashTable *ht1, HashTable *ht2, compare_func_t compar, zend_bool ordered) {
|
||||
|
@ -262,7 +262,7 @@ ZEND_API void zend_hash_bucket_swap(Bucket *p, Bucket *q);
|
||||
ZEND_API void zend_hash_bucket_renum_swap(Bucket *p, Bucket *q);
|
||||
ZEND_API void zend_hash_bucket_packed_swap(Bucket *p, Bucket *q);
|
||||
ZEND_API int zend_hash_compare(HashTable *ht1, HashTable *ht2, compare_func_t compar, zend_bool ordered);
|
||||
ZEND_API int ZEND_FASTCALL zend_hash_sort_ex(HashTable *ht, sort_func_t sort_func, compare_func_t compare_func, zend_bool renumber);
|
||||
ZEND_API void ZEND_FASTCALL zend_hash_sort_ex(HashTable *ht, sort_func_t sort_func, compare_func_t compare_func, zend_bool renumber);
|
||||
ZEND_API zval* ZEND_FASTCALL zend_hash_minmax(const HashTable *ht, compare_func_t compar, uint32_t flag);
|
||||
|
||||
#define zend_hash_sort(ht, compare_func, renumber) \
|
||||
|
@ -264,15 +264,11 @@ ZEND_API void zend_ts_hash_merge_ex(TsHashTable *target, TsHashTable *source, co
|
||||
end_read(source);
|
||||
}
|
||||
|
||||
ZEND_API int zend_ts_hash_sort(TsHashTable *ht, sort_func_t sort_func, compare_func_t compare_func, int renumber)
|
||||
ZEND_API void zend_ts_hash_sort(TsHashTable *ht, sort_func_t sort_func, compare_func_t compare_func, int renumber)
|
||||
{
|
||||
int retval;
|
||||
|
||||
begin_write(ht);
|
||||
retval = zend_hash_sort_ex(TS_HASH(ht), sort_func, compare_func, renumber);
|
||||
zend_hash_sort_ex(TS_HASH(ht), sort_func, compare_func, renumber);
|
||||
end_write(ht);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
ZEND_API int zend_ts_hash_compare(TsHashTable *ht1, TsHashTable *ht2, compare_func_t compar, zend_bool ordered)
|
||||
|
@ -73,7 +73,7 @@ ZEND_API void zend_ts_hash_copy(TsHashTable *target, TsHashTable *source, copy_c
|
||||
ZEND_API void zend_ts_hash_copy_to_hash(HashTable *target, TsHashTable *source, copy_ctor_func_t pCopyConstructor);
|
||||
ZEND_API void zend_ts_hash_merge(TsHashTable *target, TsHashTable *source, copy_ctor_func_t pCopyConstructor, int overwrite);
|
||||
ZEND_API void zend_ts_hash_merge_ex(TsHashTable *target, TsHashTable *source, copy_ctor_func_t pCopyConstructor, merge_checker_func_t pMergeSource, void *pParam);
|
||||
ZEND_API int zend_ts_hash_sort(TsHashTable *ht, sort_func_t sort_func, compare_func_t compare_func, int renumber);
|
||||
ZEND_API void zend_ts_hash_sort(TsHashTable *ht, sort_func_t sort_func, compare_func_t compare_func, int renumber);
|
||||
ZEND_API int zend_ts_hash_compare(TsHashTable *ht1, TsHashTable *ht2, compare_func_t compar, zend_bool ordered);
|
||||
ZEND_API zval *zend_ts_hash_minmax(TsHashTable *ht, compare_func_t compar, int flag);
|
||||
|
||||
|
@ -285,10 +285,7 @@ PHAR_ADD_ENTRY:
|
||||
|
||||
if (FAILURE != zend_hash_has_more_elements(data)) {
|
||||
efree(dir);
|
||||
if (zend_hash_sort(data, phar_compare_dir_name, 0) == FAILURE) {
|
||||
FREE_HASHTABLE(data);
|
||||
return NULL;
|
||||
}
|
||||
zend_hash_sort(data, phar_compare_dir_name, 0);
|
||||
return php_stream_alloc(&phar_dir_ops, data, NULL, "r");
|
||||
} else {
|
||||
efree(dir);
|
||||
|
@ -708,9 +708,8 @@ PHP_FUNCTION(krsort)
|
||||
|
||||
cmp = php_get_key_compare_func(sort_type, 1);
|
||||
|
||||
if (zend_hash_sort(Z_ARRVAL_P(array), cmp, 0) == FAILURE) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
zend_hash_sort(Z_ARRVAL_P(array), cmp, 0);
|
||||
|
||||
RETURN_TRUE;
|
||||
}
|
||||
/* }}} */
|
||||
@ -731,9 +730,8 @@ PHP_FUNCTION(ksort)
|
||||
|
||||
cmp = php_get_key_compare_func(sort_type, 0);
|
||||
|
||||
if (zend_hash_sort(Z_ARRVAL_P(array), cmp, 0) == FAILURE) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
zend_hash_sort(Z_ARRVAL_P(array), cmp, 0);
|
||||
|
||||
RETURN_TRUE;
|
||||
}
|
||||
/* }}} */
|
||||
@ -835,13 +833,9 @@ static void php_natsort(INTERNAL_FUNCTION_PARAMETERS, int fold_case) /* {{{ */
|
||||
ZEND_PARSE_PARAMETERS_END();
|
||||
|
||||
if (fold_case) {
|
||||
if (zend_hash_sort(Z_ARRVAL_P(array), php_array_natural_case_compare, 0) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
zend_hash_sort(Z_ARRVAL_P(array), php_array_natural_case_compare, 0);
|
||||
} else {
|
||||
if (zend_hash_sort(Z_ARRVAL_P(array), php_array_natural_compare, 0) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
zend_hash_sort(Z_ARRVAL_P(array), php_array_natural_compare, 0);
|
||||
}
|
||||
|
||||
RETURN_TRUE;
|
||||
@ -880,9 +874,8 @@ PHP_FUNCTION(asort)
|
||||
|
||||
cmp = php_get_data_compare_func(sort_type, 0);
|
||||
|
||||
if (zend_hash_sort(Z_ARRVAL_P(array), cmp, 0) == FAILURE) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
zend_hash_sort(Z_ARRVAL_P(array), cmp, 0);
|
||||
|
||||
RETURN_TRUE;
|
||||
}
|
||||
/* }}} */
|
||||
@ -903,9 +896,8 @@ PHP_FUNCTION(arsort)
|
||||
|
||||
cmp = php_get_data_compare_func(sort_type, 1);
|
||||
|
||||
if (zend_hash_sort(Z_ARRVAL_P(array), cmp, 0) == FAILURE) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
zend_hash_sort(Z_ARRVAL_P(array), cmp, 0);
|
||||
|
||||
RETURN_TRUE;
|
||||
}
|
||||
/* }}} */
|
||||
@ -926,9 +918,8 @@ PHP_FUNCTION(sort)
|
||||
|
||||
cmp = php_get_data_compare_func(sort_type, 0);
|
||||
|
||||
if (zend_hash_sort(Z_ARRVAL_P(array), cmp, 1) == FAILURE) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
zend_hash_sort(Z_ARRVAL_P(array), cmp, 1);
|
||||
|
||||
RETURN_TRUE;
|
||||
}
|
||||
/* }}} */
|
||||
@ -949,9 +940,8 @@ PHP_FUNCTION(rsort)
|
||||
|
||||
cmp = php_get_data_compare_func(sort_type, 1);
|
||||
|
||||
if (zend_hash_sort(Z_ARRVAL_P(array), cmp, 1) == FAILURE) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
zend_hash_sort(Z_ARRVAL_P(array), cmp, 1);
|
||||
|
||||
RETURN_TRUE;
|
||||
}
|
||||
/* }}} */
|
||||
@ -1021,7 +1011,6 @@ static void php_usort(INTERNAL_FUNCTION_PARAMETERS, compare_func_t compare_func,
|
||||
{
|
||||
zval *array;
|
||||
zend_array *arr;
|
||||
zend_bool retval;
|
||||
PHP_ARRAY_CMP_FUNC_VARS;
|
||||
|
||||
PHP_ARRAY_CMP_FUNC_BACKUP();
|
||||
@ -1040,13 +1029,13 @@ static void php_usort(INTERNAL_FUNCTION_PARAMETERS, compare_func_t compare_func,
|
||||
/* Copy array, so the in-place modifications will not be visible to the callback function */
|
||||
arr = zend_array_dup(arr);
|
||||
|
||||
retval = zend_hash_sort(arr, compare_func, renumber) != FAILURE;
|
||||
zend_hash_sort(arr, compare_func, renumber);
|
||||
|
||||
zval_ptr_dtor(array);
|
||||
ZVAL_ARR(array, arr);
|
||||
|
||||
PHP_ARRAY_CMP_FUNC_RESTORE();
|
||||
RETURN_BOOL(retval);
|
||||
RETURN_TRUE;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user