mirror of
https://github.com/php/php-src.git
synced 2025-01-27 14:13:41 +08:00
optimize zend_hash_init() with known hash table sizes.
This commit is contained in:
parent
59fabbb464
commit
8581c7328f
@ -3055,7 +3055,7 @@ static void php_array_intersect(INTERNAL_FUNCTION_PARAMETERS, int behavior, int
|
||||
zval *tmp;
|
||||
|
||||
ALLOC_HASHTABLE(ht);
|
||||
zend_hash_init(ht, 0, NULL, ZVAL_PTR_DTOR, 0);
|
||||
zend_hash_init(ht, zend_hash_num_elements(return_value->value.ht), NULL, ZVAL_PTR_DTOR, 0);
|
||||
zend_hash_copy(ht, return_value->value.ht, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
|
||||
return_value->value.ht = ht;
|
||||
}
|
||||
@ -3441,7 +3441,7 @@ static void php_array_diff(INTERNAL_FUNCTION_PARAMETERS, int behavior, int data_
|
||||
zval *tmp;
|
||||
|
||||
ALLOC_HASHTABLE(ht);
|
||||
zend_hash_init(ht, 0, NULL, ZVAL_PTR_DTOR, 0);
|
||||
zend_hash_init(ht, zend_hash_num_elements(return_value->value.ht), NULL, ZVAL_PTR_DTOR, 0);
|
||||
zend_hash_copy(ht, return_value->value.ht, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
|
||||
return_value->value.ht = ht;
|
||||
}
|
||||
|
@ -614,7 +614,7 @@ static int stream_array_from_fd_set(zval *stream_array, fd_set *fds TSRMLS_DC)
|
||||
return 0;
|
||||
}
|
||||
ALLOC_HASHTABLE(new_hash);
|
||||
zend_hash_init(new_hash, 0, NULL, ZVAL_PTR_DTOR, 0);
|
||||
zend_hash_init(new_hash, zend_hash_num_elements(Z_ARRVAL_P(stream_array)), NULL, ZVAL_PTR_DTOR, 0);
|
||||
|
||||
for (zend_hash_internal_pointer_reset(Z_ARRVAL_P(stream_array));
|
||||
zend_hash_get_current_data(Z_ARRVAL_P(stream_array), (void **) &elem) == SUCCESS;
|
||||
@ -662,7 +662,7 @@ static int stream_array_emulate_read_fd_set(zval *stream_array TSRMLS_DC)
|
||||
return 0;
|
||||
}
|
||||
ALLOC_HASHTABLE(new_hash);
|
||||
zend_hash_init(new_hash, 0, NULL, ZVAL_PTR_DTOR, 0);
|
||||
zend_hash_init(new_hash, zend_hash_num_elements(Z_ARRVAL_P(stream_array)), NULL, ZVAL_PTR_DTOR, 0);
|
||||
|
||||
for (zend_hash_internal_pointer_reset(Z_ARRVAL_P(stream_array));
|
||||
zend_hash_get_current_data(Z_ARRVAL_P(stream_array), (void **) &elem) == SUCCESS;
|
||||
|
@ -2496,7 +2496,7 @@ static void php_strtr_array(zval *return_value, char *str, int slen, HashTable *
|
||||
smart_str result = {0};
|
||||
HashTable tmp_hash;
|
||||
|
||||
zend_hash_init(&tmp_hash, 0, NULL, NULL, 0);
|
||||
zend_hash_init(&tmp_hash, zend_hash_num_elements(hash), NULL, NULL, 0);
|
||||
zend_hash_internal_pointer_reset_ex(hash, &hpos);
|
||||
while (zend_hash_get_current_data_ex(hash, (void **)&entry, &hpos) == SUCCESS) {
|
||||
switch (zend_hash_get_current_key_ex(hash, &string_key, &string_key_len, &num_key, 0, &hpos)) {
|
||||
|
Loading…
Reference in New Issue
Block a user