PHP  
 PHP: Test and Code Coverage Analysis
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

LCOV - code coverage report
Current view: top level - Zend - zend_hash.h (source / functions) Hit Total Coverage
Test: PHP Code Coverage Lines: 162 170 95.3 %
Date: 2015-05-21 Functions: 0 0 -
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :    +----------------------------------------------------------------------+
       3             :    | Zend Engine                                                          |
       4             :    +----------------------------------------------------------------------+
       5             :    | Copyright (c) 1998-2015 Zend Technologies Ltd. (http://www.zend.com) |
       6             :    +----------------------------------------------------------------------+
       7             :    | This source file is subject to version 2.00 of the Zend license,     |
       8             :    | that is bundled with this package in the file LICENSE, and is        |
       9             :    | available through the world-wide-web at the following url:           |
      10             :    | http://www.zend.com/license/2_00.txt.                                |
      11             :    | If you did not receive a copy of the Zend license and are unable to  |
      12             :    | obtain it through the world-wide-web, please send a note to          |
      13             :    | license@zend.com so we can mail you a copy immediately.              |
      14             :    +----------------------------------------------------------------------+
      15             :    | Authors: Andi Gutmans <andi@zend.com>                                |
      16             :    |          Zeev Suraski <zeev@zend.com>                                |
      17             :    +----------------------------------------------------------------------+
      18             : */
      19             : 
      20             : /* $Id$ */
      21             : 
      22             : #ifndef ZEND_HASH_H
      23             : #define ZEND_HASH_H
      24             : 
      25             : #include "zend.h"
      26             : 
      27             : #define HASH_KEY_IS_STRING 1
      28             : #define HASH_KEY_IS_LONG 2
      29             : #define HASH_KEY_NON_EXISTENT 3
      30             : 
      31             : #define HASH_UPDATE                     (1<<0)
      32             : #define HASH_ADD                                (1<<1)
      33             : #define HASH_UPDATE_INDIRECT    (1<<2)
      34             : #define HASH_ADD_NEW                    (1<<3)
      35             : #define HASH_ADD_NEXT                   (1<<4)
      36             : 
      37             : #define HASH_FLAG_PERSISTENT       (1<<0)
      38             : #define HASH_FLAG_APPLY_PROTECTION (1<<1)
      39             : #define HASH_FLAG_PACKED           (1<<2)
      40             : #define HASH_FLAG_INITIALIZED      (1<<3)
      41             : #define HASH_FLAG_STATIC_KEYS      (1<<4)
      42             : 
      43             : #define HASH_MASK_CONSISTENCY      0x60
      44             : 
      45             : typedef struct _zend_hash_key {
      46             :         zend_ulong h;
      47             :         zend_string *key;
      48             : } zend_hash_key;
      49             : 
      50             : typedef zend_bool (*merge_checker_func_t)(HashTable *target_ht, zval *source_data, zend_hash_key *hash_key, void *pParam);
      51             : 
      52             : BEGIN_EXTERN_C()
      53             : 
      54             : /* startup/shutdown */
      55             : ZEND_API void ZEND_FASTCALL _zend_hash_init(HashTable *ht, uint32_t nSize, dtor_func_t pDestructor, zend_bool persistent ZEND_FILE_LINE_DC);
      56             : ZEND_API void ZEND_FASTCALL _zend_hash_init_ex(HashTable *ht, uint32_t nSize, dtor_func_t pDestructor, zend_bool persistent, zend_bool bApplyProtection ZEND_FILE_LINE_DC);
      57             : ZEND_API void ZEND_FASTCALL zend_hash_destroy(HashTable *ht);
      58             : ZEND_API void ZEND_FASTCALL zend_hash_clean(HashTable *ht);
      59             : #define zend_hash_init(ht, nSize, pHashFunction, pDestructor, persistent)                                               _zend_hash_init((ht), (nSize), (pDestructor), (persistent) ZEND_FILE_LINE_CC)
      60             : #define zend_hash_init_ex(ht, nSize, pHashFunction, pDestructor, persistent, bApplyProtection)          _zend_hash_init_ex((ht), (nSize), (pDestructor), (persistent), (bApplyProtection) ZEND_FILE_LINE_CC)
      61             : 
      62             : ZEND_API void ZEND_FASTCALL zend_hash_real_init(HashTable *ht, zend_bool packed);
      63             : ZEND_API void ZEND_FASTCALL zend_hash_packed_to_hash(HashTable *ht);
      64             : ZEND_API void ZEND_FASTCALL zend_hash_to_packed(HashTable *ht);
      65             : ZEND_API void ZEND_FASTCALL zend_hash_extend(HashTable *ht, uint32_t nSize, zend_bool packed);
      66             : 
      67             : /* additions/updates/changes */
      68             : ZEND_API zval* ZEND_FASTCALL _zend_hash_add_or_update(HashTable *ht, zend_string *key, zval *pData, uint32_t flag ZEND_FILE_LINE_DC);
      69             : ZEND_API zval* ZEND_FASTCALL _zend_hash_update(HashTable *ht, zend_string *key,zval *pData ZEND_FILE_LINE_DC);
      70             : ZEND_API zval* ZEND_FASTCALL _zend_hash_update_ind(HashTable *ht, zend_string *key,zval *pData ZEND_FILE_LINE_DC);
      71             : ZEND_API zval* ZEND_FASTCALL _zend_hash_add(HashTable *ht, zend_string *key,zval *pData ZEND_FILE_LINE_DC);
      72             : ZEND_API zval* ZEND_FASTCALL _zend_hash_add_new(HashTable *ht, zend_string *key,zval *pData ZEND_FILE_LINE_DC);
      73             : 
      74             : #define zend_hash_update(ht, key, pData) \
      75             :                 _zend_hash_update(ht, key, pData ZEND_FILE_LINE_CC)
      76             : #define zend_hash_update_ind(ht, key, pData) \
      77             :                 _zend_hash_update_ind(ht, key, pData ZEND_FILE_LINE_CC)
      78             : #define zend_hash_add(ht, key, pData) \
      79             :                 _zend_hash_add(ht, key, pData ZEND_FILE_LINE_CC)
      80             : #define zend_hash_add_new(ht, key, pData) \
      81             :                 _zend_hash_add_new(ht, key, pData ZEND_FILE_LINE_CC)
      82             : 
      83             : ZEND_API zval* ZEND_FASTCALL _zend_hash_str_add_or_update(HashTable *ht, const char *key, size_t len, zval *pData, uint32_t flag ZEND_FILE_LINE_DC);
      84             : ZEND_API zval* ZEND_FASTCALL _zend_hash_str_update(HashTable *ht, const char *key, size_t len, zval *pData ZEND_FILE_LINE_DC);
      85             : ZEND_API zval* ZEND_FASTCALL _zend_hash_str_update_ind(HashTable *ht, const char *key, size_t len, zval *pData ZEND_FILE_LINE_DC);
      86             : ZEND_API zval* ZEND_FASTCALL _zend_hash_str_add(HashTable *ht, const char *key, size_t len, zval *pData ZEND_FILE_LINE_DC);
      87             : ZEND_API zval* ZEND_FASTCALL _zend_hash_str_add_new(HashTable *ht, const char *key, size_t len, zval *pData ZEND_FILE_LINE_DC);
      88             : 
      89             : #define zend_hash_str_update(ht, key, len, pData) \
      90             :                 _zend_hash_str_update(ht, key, len, pData ZEND_FILE_LINE_CC)
      91             : #define zend_hash_str_update_ind(ht, key, len, pData) \
      92             :                 _zend_hash_str_update_ind(ht, key, len, pData ZEND_FILE_LINE_CC)
      93             : #define zend_hash_str_add(ht, key, len, pData) \
      94             :                 _zend_hash_str_add(ht, key, len, pData ZEND_FILE_LINE_CC)
      95             : #define zend_hash_str_add_new(ht, key, len, pData) \
      96             :                 _zend_hash_str_add_new(ht, key, len, pData ZEND_FILE_LINE_CC)
      97             : 
      98             : ZEND_API zval* ZEND_FASTCALL _zend_hash_index_add_or_update(HashTable *ht, zend_ulong h, zval *pData, uint32_t flag ZEND_FILE_LINE_DC);
      99             : ZEND_API zval* ZEND_FASTCALL _zend_hash_index_add(HashTable *ht, zend_ulong h, zval *pData ZEND_FILE_LINE_DC);
     100             : ZEND_API zval* ZEND_FASTCALL _zend_hash_index_add_new(HashTable *ht, zend_ulong h, zval *pData ZEND_FILE_LINE_DC);
     101             : ZEND_API zval* ZEND_FASTCALL _zend_hash_index_update(HashTable *ht, zend_ulong h, zval *pData ZEND_FILE_LINE_DC);
     102             : ZEND_API zval* ZEND_FASTCALL _zend_hash_next_index_insert(HashTable *ht, zval *pData ZEND_FILE_LINE_DC);
     103             : ZEND_API zval* ZEND_FASTCALL _zend_hash_next_index_insert_new(HashTable *ht, zval *pData ZEND_FILE_LINE_DC);
     104             : 
     105             : #define zend_hash_index_add(ht, h, pData) \
     106             :                 _zend_hash_index_add(ht, h, pData ZEND_FILE_LINE_CC)
     107             : #define zend_hash_index_add_new(ht, h, pData) \
     108             :                 _zend_hash_index_add_new(ht, h, pData ZEND_FILE_LINE_CC)
     109             : #define zend_hash_index_update(ht, h, pData) \
     110             :                 _zend_hash_index_update(ht, h, pData ZEND_FILE_LINE_CC)
     111             : #define zend_hash_next_index_insert(ht, pData) \
     112             :                 _zend_hash_next_index_insert(ht, pData ZEND_FILE_LINE_CC)
     113             : #define zend_hash_next_index_insert_new(ht, pData) \
     114             :                 _zend_hash_next_index_insert_new(ht, pData ZEND_FILE_LINE_CC)
     115             : 
     116             : ZEND_API zval* ZEND_FASTCALL zend_hash_index_add_empty_element(HashTable *ht, zend_ulong h);
     117             : ZEND_API zval* ZEND_FASTCALL zend_hash_add_empty_element(HashTable *ht, zend_string *key);
     118             : ZEND_API zval* ZEND_FASTCALL zend_hash_str_add_empty_element(HashTable *ht, const char *key, size_t len);
     119             : 
     120             : #define ZEND_HASH_APPLY_KEEP                            0
     121             : #define ZEND_HASH_APPLY_REMOVE                          1<<0
     122             : #define ZEND_HASH_APPLY_STOP                            1<<1
     123             : 
     124             : typedef int (*apply_func_t)(zval *pDest);
     125             : typedef int (*apply_func_arg_t)(zval *pDest, void *argument);
     126             : typedef int (*apply_func_args_t)(zval *pDest, int num_args, va_list args, zend_hash_key *hash_key);
     127             : 
     128             : ZEND_API void ZEND_FASTCALL zend_hash_graceful_destroy(HashTable *ht);
     129             : ZEND_API void ZEND_FASTCALL zend_hash_graceful_reverse_destroy(HashTable *ht);
     130             : ZEND_API void ZEND_FASTCALL zend_hash_apply(HashTable *ht, apply_func_t apply_func);
     131             : ZEND_API void ZEND_FASTCALL zend_hash_apply_with_argument(HashTable *ht, apply_func_arg_t apply_func, void *);
     132             : ZEND_API void ZEND_FASTCALL zend_hash_apply_with_arguments(HashTable *ht, apply_func_args_t apply_func, int, ...);
     133             : 
     134             : /* This function should be used with special care (in other words,
     135             :  * it should usually not be used).  When used with the ZEND_HASH_APPLY_STOP
     136             :  * return value, it assumes things about the order of the elements in the hash.
     137             :  * Also, it does not provide the same kind of reentrancy protection that
     138             :  * the standard apply functions do.
     139             :  */
     140             : ZEND_API void ZEND_FASTCALL zend_hash_reverse_apply(HashTable *ht, apply_func_t apply_func);
     141             : 
     142             : 
     143             : /* Deletes */
     144             : ZEND_API int ZEND_FASTCALL zend_hash_del(HashTable *ht, zend_string *key);
     145             : ZEND_API int ZEND_FASTCALL zend_hash_del_ind(HashTable *ht, zend_string *key);
     146             : ZEND_API int ZEND_FASTCALL zend_hash_str_del(HashTable *ht, const char *key, size_t len);
     147             : ZEND_API int ZEND_FASTCALL zend_hash_str_del_ind(HashTable *ht, const char *key, size_t len);
     148             : ZEND_API int ZEND_FASTCALL zend_hash_index_del(HashTable *ht, zend_ulong h);
     149             : ZEND_API void ZEND_FASTCALL zend_hash_del_bucket(HashTable *ht, Bucket *p);
     150             : 
     151             : /* Data retreival */
     152             : ZEND_API zval* ZEND_FASTCALL zend_hash_find(const HashTable *ht, zend_string *key);
     153             : ZEND_API zval* ZEND_FASTCALL zend_hash_str_find(const HashTable *ht, const char *key, size_t len);
     154             : ZEND_API zval* ZEND_FASTCALL zend_hash_index_find(const HashTable *ht, zend_ulong h);
     155             : 
     156             : /* Misc */
     157             : ZEND_API zend_bool ZEND_FASTCALL zend_hash_exists(const HashTable *ht, zend_string *key);
     158             : ZEND_API zend_bool ZEND_FASTCALL zend_hash_str_exists(const HashTable *ht, const char *str, size_t len);
     159             : ZEND_API zend_bool ZEND_FASTCALL zend_hash_index_exists(const HashTable *ht, zend_ulong h);
     160             : 
     161             : /* traversing */
     162             : #define zend_hash_has_more_elements_ex(ht, pos) \
     163             :         (zend_hash_get_current_key_type_ex(ht, pos) == HASH_KEY_NON_EXISTENT ? FAILURE : SUCCESS)
     164             : ZEND_API int   ZEND_FASTCALL zend_hash_move_forward_ex(HashTable *ht, HashPosition *pos);
     165             : ZEND_API int   ZEND_FASTCALL zend_hash_move_backwards_ex(HashTable *ht, HashPosition *pos);
     166             : ZEND_API int   ZEND_FASTCALL zend_hash_get_current_key_ex(const HashTable *ht, zend_string **str_index, zend_ulong *num_index, HashPosition *pos);
     167             : ZEND_API void  ZEND_FASTCALL zend_hash_get_current_key_zval_ex(const HashTable *ht, zval *key, HashPosition *pos);
     168             : ZEND_API int   ZEND_FASTCALL zend_hash_get_current_key_type_ex(HashTable *ht, HashPosition *pos);
     169             : ZEND_API zval* ZEND_FASTCALL zend_hash_get_current_data_ex(HashTable *ht, HashPosition *pos);
     170             : ZEND_API void  ZEND_FASTCALL zend_hash_internal_pointer_reset_ex(HashTable *ht, HashPosition *pos);
     171             : ZEND_API void  ZEND_FASTCALL zend_hash_internal_pointer_end_ex(HashTable *ht, HashPosition *pos);
     172             : 
     173             : #define zend_hash_has_more_elements(ht) \
     174             :         zend_hash_has_more_elements_ex(ht, &(ht)->nInternalPointer)
     175             : #define zend_hash_move_forward(ht) \
     176             :         zend_hash_move_forward_ex(ht, &(ht)->nInternalPointer)
     177             : #define zend_hash_move_backwards(ht) \
     178             :         zend_hash_move_backwards_ex(ht, &(ht)->nInternalPointer)
     179             : #define zend_hash_get_current_key(ht, str_index, num_index) \
     180             :         zend_hash_get_current_key_ex(ht, str_index, num_index, &(ht)->nInternalPointer)
     181             : #define zend_hash_get_current_key_zval(ht, key) \
     182             :         zend_hash_get_current_key_zval_ex(ht, key, &(ht)->nInternalPointer)
     183             : #define zend_hash_get_current_key_type(ht) \
     184             :         zend_hash_get_current_key_type_ex(ht, &(ht)->nInternalPointer)
     185             : #define zend_hash_get_current_data(ht) \
     186             :         zend_hash_get_current_data_ex(ht, &(ht)->nInternalPointer)
     187             : #define zend_hash_internal_pointer_reset(ht) \
     188             :         zend_hash_internal_pointer_reset_ex(ht, &(ht)->nInternalPointer)
     189             : #define zend_hash_internal_pointer_end(ht) \
     190             :         zend_hash_internal_pointer_end_ex(ht, &(ht)->nInternalPointer)
     191             : 
     192             : /* Copying, merging and sorting */
     193             : ZEND_API void  ZEND_FASTCALL zend_hash_copy(HashTable *target, HashTable *source, copy_ctor_func_t pCopyConstructor);
     194             : ZEND_API void  ZEND_FASTCALL _zend_hash_merge(HashTable *target, HashTable *source, copy_ctor_func_t pCopyConstructor, zend_bool overwrite ZEND_FILE_LINE_DC);
     195             : ZEND_API void  ZEND_FASTCALL zend_hash_merge_ex(HashTable *target, HashTable *source, copy_ctor_func_t pCopyConstructor, merge_checker_func_t pMergeSource, void *pParam);
     196             : ZEND_API void  zend_hash_bucket_swap(Bucket *p, Bucket *q);
     197             : ZEND_API void  zend_hash_bucket_renum_swap(Bucket *p, Bucket *q);
     198             : ZEND_API void  zend_hash_bucket_packed_swap(Bucket *p, Bucket *q);
     199             : ZEND_API int   zend_hash_compare(HashTable *ht1, HashTable *ht2, compare_func_t compar, zend_bool ordered);
     200             : ZEND_API int   ZEND_FASTCALL zend_hash_sort_ex(HashTable *ht, sort_func_t sort_func, compare_func_t compare_func, zend_bool renumber);
     201             : ZEND_API zval* ZEND_FASTCALL zend_hash_minmax(const HashTable *ht, compare_func_t compar, uint32_t flag);
     202             : 
     203             : #define zend_hash_merge(target, source, pCopyConstructor, overwrite)                                    \
     204             :         _zend_hash_merge(target, source, pCopyConstructor, overwrite ZEND_FILE_LINE_CC)
     205             : 
     206             : #define zend_hash_sort(ht, compare_func, renumber) \
     207             :         zend_hash_sort_ex(ht, zend_sort, compare_func, renumber)
     208             : 
     209             : #define zend_hash_num_elements(ht) \
     210             :         (ht)->nNumOfElements
     211             : 
     212             : #define zend_hash_next_free_element(ht) \
     213             :         (ht)->nNextFreeElement
     214             : 
     215             : ZEND_API int ZEND_FASTCALL zend_hash_rehash(HashTable *ht);
     216             : 
     217             : ZEND_API HashTable* ZEND_FASTCALL zend_array_dup(HashTable *source);
     218             : ZEND_API void ZEND_FASTCALL zend_array_destroy(HashTable *ht);
     219             : ZEND_API void ZEND_FASTCALL zend_symtable_clean(HashTable *ht);
     220             : 
     221             : ZEND_API int ZEND_FASTCALL _zend_handle_numeric_str_ex(const char *key, size_t length, zend_ulong *idx);
     222             : 
     223             : ZEND_API uint32_t     ZEND_FASTCALL zend_hash_iterator_add(HashTable *ht, HashPosition pos);
     224             : ZEND_API HashPosition ZEND_FASTCALL zend_hash_iterator_pos(uint32_t idx, HashTable *ht);
     225             : ZEND_API void         ZEND_FASTCALL zend_hash_iterator_del(uint32_t idx);
     226             : ZEND_API HashPosition ZEND_FASTCALL zend_hash_iterators_lower_pos(HashTable *ht, HashPosition start);
     227             : ZEND_API void         ZEND_FASTCALL _zend_hash_iterators_update(HashTable *ht, HashPosition from, HashPosition to);
     228             : 
     229             : static zend_always_inline void zend_hash_iterators_update(HashTable *ht, HashPosition from, HashPosition to)
     230             : {
     231   195850668 :         if (UNEXPECTED(ht->u.v.nIteratorsCount)) {
     232         237 :                 _zend_hash_iterators_update(ht, from, to);
     233             :         }
     234             : }
     235             : 
     236             : 
     237             : END_EXTERN_C()
     238             : 
     239             : #define ZEND_INIT_SYMTABLE(ht)                                                          \
     240             :         ZEND_INIT_SYMTABLE_EX(ht, 8, 0)
     241             : 
     242             : #define ZEND_INIT_SYMTABLE_EX(ht, n, persistent)                        \
     243             :         zend_hash_init(ht, n, NULL, ZVAL_PTR_DTOR, persistent)
     244             : 
     245             : static zend_always_inline int _zend_handle_numeric_str(const char *key, size_t length, zend_ulong *idx)
     246             : {
     247     5082246 :         register const char *tmp = key;
     248             : 
     249     5082246 :         if (*tmp > '9') {
     250     4663133 :                 return 0;
     251      419113 :         } else if (*tmp < '0') {
     252       36054 :                 if (*tmp != '-') {
     253       35973 :                         return 0;
     254             :                 }
     255          81 :                 tmp++;
     256          81 :                 if (*tmp > '9' || *tmp < '0') {
     257          22 :                         return 0;
     258             :                 }
     259             :         }
     260      383118 :         return _zend_handle_numeric_str_ex(key, length, idx);
     261             : }
     262             : 
     263             : #define ZEND_HANDLE_NUMERIC_STR(key, length, idx) \
     264             :         _zend_handle_numeric_str(key, length, &idx)
     265             : 
     266             : #define ZEND_HANDLE_NUMERIC(key, idx) \
     267             :         ZEND_HANDLE_NUMERIC_STR((key)->val, (key)->len, idx)
     268             : 
     269             : 
     270             : static zend_always_inline zval *zend_hash_find_ind(const HashTable *ht, zend_string *key)
     271             : {
     272             :         zval *zv;
     273             : 
     274      274955 :         zv = zend_hash_find(ht, key);
     275      304784 :         return (zv && Z_TYPE_P(zv) == IS_INDIRECT) ? 
     276          86 :                 ((Z_TYPE_P(Z_INDIRECT_P(zv)) != IS_UNDEF) ? Z_INDIRECT_P(zv) : NULL) : zv;
     277             : }
     278             : 
     279             : 
     280             : static zend_always_inline int zend_hash_exists_ind(const HashTable *ht, zend_string *key)
     281             : {
     282             :         zval *zv;
     283             : 
     284         219 :         zv = zend_hash_find(ht, key);
     285         378 :         return zv && (Z_TYPE_P(zv) != IS_INDIRECT ||
     286          27 :                         Z_TYPE_P(Z_INDIRECT_P(zv)) != IS_UNDEF);
     287             : }
     288             : 
     289             : 
     290             : static zend_always_inline zval *zend_hash_str_find_ind(const HashTable *ht, const char *str, size_t len)
     291             : {
     292             :         zval *zv;
     293             : 
     294         739 :         zv = zend_hash_str_find(ht, str, len);
     295        2143 :         return (zv && Z_TYPE_P(zv) == IS_INDIRECT) ? 
     296        1336 :                 ((Z_TYPE_P(Z_INDIRECT_P(zv)) != IS_UNDEF) ? Z_INDIRECT_P(zv) : NULL) : zv;
     297             : }
     298             : 
     299             : 
     300             : static zend_always_inline zval *zend_symtable_update(HashTable *ht, zend_string *key, zval *pData)
     301             : {
     302             :         zend_ulong idx;
     303             : 
     304       45492 :         if (ZEND_HANDLE_NUMERIC(key, idx)) {
     305        1137 :                 return zend_hash_index_update(ht, idx, pData);
     306             :         } else {
     307       21609 :                 return zend_hash_update(ht, key, pData);
     308             :         }
     309             : }
     310             : 
     311             : 
     312             : static zend_always_inline zval *zend_symtable_update_ind(HashTable *ht, zend_string *key, zval *pData)
     313             : {
     314             :         zend_ulong idx;
     315             : 
     316         120 :         if (ZEND_HANDLE_NUMERIC(key, idx)) {
     317           1 :                 return zend_hash_index_update(ht, idx, pData);
     318             :         } else {
     319          59 :                 return zend_hash_update_ind(ht, key, pData);
     320             :         }
     321             : }
     322             : 
     323             : 
     324             : static zend_always_inline int zend_symtable_del(HashTable *ht, zend_string *key)
     325             : {
     326             :         zend_ulong idx;
     327             : 
     328          32 :         if (ZEND_HANDLE_NUMERIC(key, idx)) {
     329           6 :                 return zend_hash_index_del(ht, idx);
     330             :         } else {
     331          10 :                 return zend_hash_del(ht, key);
     332             :         }
     333             : }
     334             : 
     335             : 
     336             : static zend_always_inline int zend_symtable_del_ind(HashTable *ht, zend_string *key)
     337             : {
     338             :         zend_ulong idx;
     339             : 
     340             :         if (ZEND_HANDLE_NUMERIC(key, idx)) {
     341             :                 return zend_hash_index_del(ht, idx);
     342             :         } else {
     343             :                 return zend_hash_del_ind(ht, key);
     344             :         }
     345             : }
     346             : 
     347             : 
     348             : static zend_always_inline zval *zend_symtable_find(const HashTable *ht, zend_string *key)
     349             : {
     350             :         zend_ulong idx;
     351             : 
     352         780 :         if (ZEND_HANDLE_NUMERIC(key, idx)) {
     353          27 :                 return zend_hash_index_find(ht, idx);
     354             :         } else {
     355         363 :                 return zend_hash_find(ht, key);
     356             :         }
     357             : }
     358             : 
     359             : 
     360             : static zend_always_inline zval *zend_symtable_find_ind(const HashTable *ht, zend_string *key)
     361             : {
     362             :         zend_ulong idx;
     363             : 
     364             :         if (ZEND_HANDLE_NUMERIC(key, idx)) {
     365             :                 return zend_hash_index_find(ht, idx);
     366             :         } else {
     367             :                 return zend_hash_find_ind(ht, key);
     368             :         }
     369             : }
     370             : 
     371             : 
     372             : static zend_always_inline int zend_symtable_exists(HashTable *ht, zend_string *key)
     373             : {
     374             :         zend_ulong idx;
     375             : 
     376      284726 :         if (ZEND_HANDLE_NUMERIC(key, idx)) {
     377          20 :                 return zend_hash_index_exists(ht, idx);
     378             :         } else {
     379      142343 :                 return zend_hash_exists(ht, key);
     380             :         }
     381             : }
     382             : 
     383             : 
     384             : static zend_always_inline zval *zend_symtable_str_update(HashTable *ht, const char *str, size_t len, zval *pData)
     385             : {
     386             :         zend_ulong idx;
     387             : 
     388      319466 :         if (ZEND_HANDLE_NUMERIC_STR(str, len, idx)) {
     389        1038 :                 return zend_hash_index_update(ht, idx, pData);
     390             :         } else {
     391      318428 :                 return zend_hash_str_update(ht, str, len, pData);
     392             :         }
     393             : }
     394             : 
     395             : 
     396             : static zend_always_inline zval *zend_symtable_str_update_ind(HashTable *ht, const char *str, size_t len, zval *pData)
     397             : {
     398             :         zend_ulong idx;
     399             : 
     400     1257525 :         if (ZEND_HANDLE_NUMERIC_STR(str, len, idx)) {
     401          28 :                 return zend_hash_index_update(ht, idx, pData);
     402             :         } else {
     403     1257497 :                 return zend_hash_str_update_ind(ht, str, len, pData);
     404             :         }
     405             : }
     406             : 
     407             : 
     408             : static zend_always_inline int zend_symtable_str_del(HashTable *ht, const char *str, size_t len)
     409             : {
     410             :         zend_ulong idx;
     411             : 
     412           8 :         if (ZEND_HANDLE_NUMERIC_STR(str, len, idx)) {
     413           2 :                 return zend_hash_index_del(ht, idx);
     414             :         } else {
     415           6 :                 return zend_hash_str_del(ht, str, len);
     416             :         }
     417             : }
     418             : 
     419             : 
     420             : static zend_always_inline int zend_symtable_str_del_ind(HashTable *ht, const char *str, size_t len)
     421             : {
     422             :         zend_ulong idx;
     423             : 
     424             :         if (ZEND_HANDLE_NUMERIC_STR(str, len, idx)) {
     425             :                 return zend_hash_index_del(ht, idx);
     426             :         } else {
     427             :                 return zend_hash_str_del_ind(ht, str, len);
     428             :         }
     429             : }
     430             : 
     431             : 
     432             : static zend_always_inline zval *zend_symtable_str_find(HashTable *ht, const char *str, size_t len)
     433             : {
     434             :         zend_ulong idx;
     435             : 
     436         412 :         if (ZEND_HANDLE_NUMERIC_STR(str, len, idx)) {
     437          23 :                 return zend_hash_index_find(ht, idx);
     438             :         } else {
     439         389 :                 return zend_hash_str_find(ht, str, len);
     440             :         }
     441             : }
     442             : 
     443             : 
     444             : static zend_always_inline int zend_symtable_str_exists(HashTable *ht, const char *str, size_t len)
     445             : {
     446             :         zend_ulong idx;
     447             : 
     448          75 :         if (ZEND_HANDLE_NUMERIC_STR(str, len, idx)) {
     449           0 :                 return zend_hash_index_exists(ht, idx);
     450             :         } else {
     451          75 :                 return zend_hash_str_exists(ht, str, len);
     452             :         }
     453             : }
     454             : 
     455             : static zend_always_inline void *zend_hash_add_ptr(HashTable *ht, zend_string *key, void *pData)
     456             : {
     457             :         zval tmp, *zv;
     458             : 
     459   133215839 :         ZVAL_PTR(&tmp, pData);
     460   133215839 :         zv = zend_hash_add(ht, key, &tmp);
     461   133215839 :         if (zv) {
     462             :                 ZEND_ASSUME(Z_PTR_P(zv));
     463   133215808 :                 return Z_PTR_P(zv);
     464             :         } else {
     465          31 :                 return NULL;
     466             :         }
     467             : }
     468             : 
     469             : static zend_always_inline void *zend_hash_add_new_ptr(HashTable *ht, zend_string *key, void *pData)
     470             : {
     471             :         zval tmp, *zv;
     472             : 
     473      355653 :         ZVAL_PTR(&tmp, pData);
     474      355653 :         zv = zend_hash_add_new(ht, key, &tmp);
     475      355653 :         if (zv) {
     476             :                 ZEND_ASSUME(Z_PTR_P(zv));
     477      355653 :                 return Z_PTR_P(zv);
     478             :         } else {
     479           0 :                 return NULL;
     480             :         }
     481             : }
     482             : 
     483             : static zend_always_inline void *zend_hash_str_add_ptr(HashTable *ht, const char *str, size_t len, void *pData)
     484             : {
     485             :         zval tmp, *zv;
     486             : 
     487     8879422 :         ZVAL_PTR(&tmp, pData);
     488     8879422 :         zv = zend_hash_str_add(ht, str, len, &tmp);
     489     8879422 :         if (zv) {
     490             :                 ZEND_ASSUME(Z_PTR_P(zv));
     491     8668573 :                 return Z_PTR_P(zv);
     492             :         } else {
     493      210849 :                 return NULL;
     494             :         }
     495             : }
     496             : 
     497             : static zend_always_inline void *zend_hash_str_add_new_ptr(HashTable *ht, const char *str, size_t len, void *pData)
     498             : {
     499             :         zval tmp, *zv;
     500             : 
     501             :         ZVAL_PTR(&tmp, pData);
     502             :         zv = zend_hash_str_add_new(ht, str, len, &tmp);
     503             :         if (zv) {
     504             :                 ZEND_ASSUME(Z_PTR_P(zv));
     505             :                 return Z_PTR_P(zv);
     506             :         } else {
     507             :                 return NULL;
     508             :         }
     509             : }
     510             : 
     511             : static zend_always_inline void *zend_hash_update_ptr(HashTable *ht, zend_string *key, void *pData)
     512             : {
     513             :         zval tmp, *zv;
     514             : 
     515     6328933 :         ZVAL_PTR(&tmp, pData);
     516     6328933 :         zv = zend_hash_update(ht, key, &tmp);
     517     6328933 :         if (zv) {
     518             :                 ZEND_ASSUME(Z_PTR_P(zv));
     519     6328933 :                 return Z_PTR_P(zv);
     520             :         } else {
     521           0 :                 return NULL;
     522             :         }
     523             : }
     524             : 
     525             : static zend_always_inline void *zend_hash_str_update_ptr(HashTable *ht, const char *str, size_t len, void *pData)
     526             : {
     527             :         zval tmp, *zv;
     528             : 
     529      503294 :         ZVAL_PTR(&tmp, pData);
     530      503294 :         zv = zend_hash_str_update(ht, str, len, &tmp);
     531      503294 :         if (zv) {
     532             :                 ZEND_ASSUME(Z_PTR_P(zv));
     533      503294 :                 return Z_PTR_P(zv);
     534             :         } else {
     535           0 :                 return NULL;
     536             :         }
     537             : }
     538             : 
     539             : static zend_always_inline void *zend_hash_add_mem(HashTable *ht, zend_string *key, void *pData, size_t size)
     540             : {
     541             :         zval tmp, *zv;
     542             : 
     543     2573135 :         ZVAL_PTR(&tmp, NULL);
     544     2573135 :         if ((zv = zend_hash_add(ht, key, &tmp))) {
     545     5146266 :                 Z_PTR_P(zv) = pemalloc(size, ht->u.flags & HASH_FLAG_PERSISTENT);
     546     2573133 :                 memcpy(Z_PTR_P(zv), pData, size);
     547     2573133 :                 return Z_PTR_P(zv);
     548             :         }
     549           2 :         return NULL;
     550             : }
     551             : 
     552             : static zend_always_inline void *zend_hash_str_add_mem(HashTable *ht, const char *str, size_t len, void *pData, size_t size)
     553             : {
     554             :         zval tmp, *zv;
     555             : 
     556     3436691 :         ZVAL_PTR(&tmp, NULL);
     557     3436691 :         if ((zv = zend_hash_str_add(ht, str, len, &tmp))) {
     558     6831516 :                 Z_PTR_P(zv) = pemalloc(size, ht->u.flags & HASH_FLAG_PERSISTENT);
     559     3415758 :                 memcpy(Z_PTR_P(zv), pData, size);
     560     3415758 :                 return Z_PTR_P(zv);
     561             :         }
     562       20933 :         return NULL;
     563             : }
     564             : 
     565             : static zend_always_inline void *zend_hash_update_mem(HashTable *ht, zend_string *key, void *pData, size_t size)
     566             : {
     567             :         void *p;
     568             : 
     569     1658970 :         p = pemalloc(size, ht->u.flags & HASH_FLAG_PERSISTENT);
     570      829485 :         memcpy(p, pData, size);
     571      829485 :         return zend_hash_update_ptr(ht, key, p);
     572             : }
     573             : 
     574             : static zend_always_inline void *zend_hash_str_update_mem(HashTable *ht, const char *str, size_t len, void *pData, size_t size)
     575             : {
     576             :         void *p;
     577             : 
     578        1984 :         p = pemalloc(size, ht->u.flags & HASH_FLAG_PERSISTENT);
     579         992 :         memcpy(p, pData, size);
     580         992 :         return zend_hash_str_update_ptr(ht, str, len, p);
     581             : }
     582             : 
     583             : static zend_always_inline void *zend_hash_index_add_ptr(HashTable *ht, zend_ulong h, void *pData)
     584             : {
     585             :         zval tmp, *zv;
     586             : 
     587         520 :         ZVAL_PTR(&tmp, pData);
     588         520 :         zv = zend_hash_index_add(ht, h, &tmp);
     589         520 :         return zv ? Z_PTR_P(zv) : NULL;
     590             : }
     591             : 
     592             : static zend_always_inline void *zend_hash_index_update_ptr(HashTable *ht, zend_ulong h, void *pData)
     593             : {
     594             :         zval tmp, *zv;
     595             : 
     596     1298972 :         ZVAL_PTR(&tmp, pData);
     597     1298972 :         zv = zend_hash_index_update(ht, h, &tmp);
     598     1298972 :         if (zv) {
     599             :                 ZEND_ASSUME(Z_PTR_P(zv));
     600     1298972 :                 return Z_PTR_P(zv);
     601             :         } else {
     602           0 :                 return NULL;
     603             :         }
     604             : }
     605             : 
     606             : static zend_always_inline void *zend_hash_index_add_mem(HashTable *ht, zend_ulong h, void *pData, size_t size)
     607             : {
     608             :         zval tmp, *zv;
     609             : 
     610             :         ZVAL_PTR(&tmp, NULL);
     611             :         if ((zv = zend_hash_index_add(ht, h, &tmp))) {
     612             :                 Z_PTR_P(zv) = pemalloc(size, ht->u.flags & HASH_FLAG_PERSISTENT);
     613             :                 memcpy(Z_PTR_P(zv), pData, size);
     614             :                 return Z_PTR_P(zv);
     615             :         }
     616             :         return NULL;
     617             : }
     618             : 
     619             : static zend_always_inline void *zend_hash_next_index_insert_ptr(HashTable *ht, void *pData)
     620             : {
     621             :         zval tmp, *zv;
     622             : 
     623       39012 :         ZVAL_PTR(&tmp, pData);
     624       39012 :         zv = zend_hash_next_index_insert(ht, &tmp);
     625       39012 :         if (zv) {
     626             :                 ZEND_ASSUME(Z_PTR_P(zv));
     627       39012 :                 return Z_PTR_P(zv);
     628             :         } else {
     629           0 :                 return NULL;
     630             :         }
     631             : }
     632             : 
     633             : static zend_always_inline void *zend_hash_index_update_mem(HashTable *ht, zend_ulong h, void *pData, size_t size)
     634             : {
     635             :         void *p;
     636             : 
     637       15270 :         p = pemalloc(size, ht->u.flags & HASH_FLAG_PERSISTENT);
     638        7635 :         memcpy(p, pData, size);
     639        7635 :         return zend_hash_index_update_ptr(ht, h, p);
     640             : }
     641             : 
     642             : static zend_always_inline void *zend_hash_next_index_insert_mem(HashTable *ht, void *pData, size_t size)
     643             : {
     644             :         zval tmp, *zv;
     645             : 
     646          79 :         ZVAL_PTR(&tmp, NULL);
     647          79 :         if ((zv = zend_hash_next_index_insert(ht, &tmp))) {
     648         158 :                 Z_PTR_P(zv) = pemalloc(size, ht->u.flags & HASH_FLAG_PERSISTENT);
     649          79 :                 memcpy(Z_PTR_P(zv), pData, size);
     650          79 :                 return Z_PTR_P(zv);
     651             :         }
     652           0 :         return NULL;
     653             : }
     654             : 
     655             : static zend_always_inline void *zend_hash_find_ptr(const HashTable *ht, zend_string *key)
     656             : {
     657             :         zval *zv;
     658             : 
     659     5473653 :         zv = zend_hash_find(ht, key);
     660     5473653 :         if (zv) {
     661             :                 ZEND_ASSUME(Z_PTR_P(zv));
     662     3216279 :                 return Z_PTR_P(zv);
     663             :         } else {
     664     2257374 :                 return NULL;
     665             :         }
     666             : }
     667             : 
     668             : static zend_always_inline void *zend_hash_str_find_ptr(const HashTable *ht, const char *str, size_t len)
     669             : {
     670             :         zval *zv;
     671             : 
     672     1342395 :         zv = zend_hash_str_find(ht, str, len);
     673     1342395 :         if (zv) {
     674             :                 ZEND_ASSUME(Z_PTR_P(zv));
     675     1285479 :                 return Z_PTR_P(zv);
     676             :         } else {
     677       56916 :                 return NULL;
     678             :         }
     679             : }
     680             : 
     681             : static zend_always_inline void *zend_hash_index_find_ptr(const HashTable *ht, zend_ulong h)
     682             : {
     683             :         zval *zv;
     684             : 
     685      267037 :         zv = zend_hash_index_find(ht, h);
     686      267037 :         if (zv) {
     687             :                 ZEND_ASSUME(Z_PTR_P(zv));
     688      259053 :                 return Z_PTR_P(zv);
     689             :         } else {
     690        7984 :                 return NULL;
     691             :         }
     692             : }
     693             : 
     694             : static zend_always_inline void *zend_symtable_str_find_ptr(HashTable *ht, const char *str, size_t len)
     695             : {
     696             :         zend_ulong idx;
     697             : 
     698             :         if (ZEND_HANDLE_NUMERIC_STR(str, len, idx)) {
     699             :                 return zend_hash_index_find_ptr(ht, idx);
     700             :         } else {
     701             :                 return zend_hash_str_find_ptr(ht, str, len);
     702             :         }
     703             : }
     704             : 
     705             : static zend_always_inline void *zend_hash_get_current_data_ptr_ex(HashTable *ht, HashPosition *pos)
     706             : {
     707             :         zval *zv;
     708             : 
     709       56367 :         zv = zend_hash_get_current_data_ex(ht, pos);
     710       56367 :         if (zv) {
     711             :                 ZEND_ASSUME(Z_PTR_P(zv));
     712       56284 :                 return Z_PTR_P(zv);
     713             :         } else {
     714          83 :                 return NULL;
     715             :         }
     716             : }
     717             : 
     718             : #define zend_hash_get_current_data_ptr(ht) \
     719             :         zend_hash_get_current_data_ptr_ex(ht, &(ht)->nInternalPointer)
     720             : 
     721             : #define ZEND_HASH_FOREACH(_ht, indirect) do { \
     722             :                 Bucket *_p = (_ht)->arData; \
     723             :                 Bucket *_end = _p + (_ht)->nNumUsed; \
     724             :                 for (; _p != _end; _p++) { \
     725             :                         zval *_z = &_p->val; \
     726             :                         if (indirect && Z_TYPE_P(_z) == IS_INDIRECT) { \
     727             :                                 _z = Z_INDIRECT_P(_z); \
     728             :                         } \
     729             :                         if (UNEXPECTED(Z_TYPE_P(_z) == IS_UNDEF)) continue;
     730             : 
     731             : #define ZEND_HASH_REVERSE_FOREACH(_ht, indirect) do { \
     732             :                 uint _idx; \
     733             :                 for (_idx = (_ht)->nNumUsed; _idx > 0; _idx--) { \
     734             :                         Bucket *_p = (_ht)->arData + _idx - 1; \
     735             :                         zval *_z = &_p->val; \
     736             :                         if (indirect && Z_TYPE_P(_z) == IS_INDIRECT) { \
     737             :                                 _z = Z_INDIRECT_P(_z); \
     738             :                         } \
     739             :                         if (UNEXPECTED(Z_TYPE_P(_z) == IS_UNDEF)) continue;
     740             : 
     741             : #define ZEND_HASH_FOREACH_END() \
     742             :                 } \
     743             :         } while (0)
     744             : 
     745             : #define ZEND_HASH_FOREACH_BUCKET(ht, _bucket) \
     746             :         ZEND_HASH_FOREACH(ht, 0); \
     747             :         _bucket = _p;
     748             : 
     749             : #define ZEND_HASH_FOREACH_VAL(ht, _val) \
     750             :         ZEND_HASH_FOREACH(ht, 0); \
     751             :         _val = _z;
     752             : 
     753             : #define ZEND_HASH_FOREACH_VAL_IND(ht, _val) \
     754             :         ZEND_HASH_FOREACH(ht, 1); \
     755             :         _val = _z;
     756             : 
     757             : #define ZEND_HASH_FOREACH_PTR(ht, _ptr) \
     758             :         ZEND_HASH_FOREACH(ht, 0); \
     759             :         _ptr = Z_PTR_P(_z);
     760             : 
     761             : #define ZEND_HASH_FOREACH_NUM_KEY(ht, _h) \
     762             :         ZEND_HASH_FOREACH(ht, 0); \
     763             :         _h = _p->h;
     764             : 
     765             : #define ZEND_HASH_FOREACH_STR_KEY(ht, _key) \
     766             :         ZEND_HASH_FOREACH(ht, 0); \
     767             :         _key = _p->key;
     768             : 
     769             : #define ZEND_HASH_FOREACH_KEY(ht, _h, _key) \
     770             :         ZEND_HASH_FOREACH(ht, 0); \
     771             :         _h = _p->h; \
     772             :         _key = _p->key;
     773             : 
     774             : #define ZEND_HASH_FOREACH_NUM_KEY_VAL(ht, _h, _val) \
     775             :         ZEND_HASH_FOREACH(ht, 0); \
     776             :         _h = _p->h; \
     777             :         _val = _z;
     778             : 
     779             : #define ZEND_HASH_FOREACH_STR_KEY_VAL(ht, _key, _val) \
     780             :         ZEND_HASH_FOREACH(ht, 0); \
     781             :         _key = _p->key; \
     782             :         _val = _z;
     783             : 
     784             : #define ZEND_HASH_FOREACH_KEY_VAL(ht, _h, _key, _val) \
     785             :         ZEND_HASH_FOREACH(ht, 0); \
     786             :         _h = _p->h; \
     787             :         _key = _p->key; \
     788             :         _val = _z;
     789             : 
     790             : #define ZEND_HASH_FOREACH_STR_KEY_VAL_IND(ht, _key, _val) \
     791             :         ZEND_HASH_FOREACH(ht, 1); \
     792             :         _key = _p->key; \
     793             :         _val = _z;
     794             : 
     795             : #define ZEND_HASH_FOREACH_KEY_VAL_IND(ht, _h, _key, _val) \
     796             :         ZEND_HASH_FOREACH(ht, 1); \
     797             :         _h = _p->h; \
     798             :         _key = _p->key; \
     799             :         _val = _z;
     800             : 
     801             : #define ZEND_HASH_FOREACH_NUM_KEY_PTR(ht, _h, _ptr) \
     802             :         ZEND_HASH_FOREACH(ht, 0); \
     803             :         _h = _p->h; \
     804             :         _ptr = Z_PTR_P(_z);
     805             : 
     806             : #define ZEND_HASH_FOREACH_STR_KEY_PTR(ht, _key, _ptr) \
     807             :         ZEND_HASH_FOREACH(ht, 0); \
     808             :         _key = _p->key; \
     809             :         _ptr = Z_PTR_P(_z);
     810             : 
     811             : #define ZEND_HASH_FOREACH_KEY_PTR(ht, _h, _key, _ptr) \
     812             :         ZEND_HASH_FOREACH(ht, 0); \
     813             :         _h = _p->h; \
     814             :         _key = _p->key; \
     815             :         _ptr = Z_PTR_P(_z);
     816             : 
     817             : #define ZEND_HASH_REVERSE_FOREACH_BUCKET(ht, _bucket) \
     818             :         ZEND_HASH_REVERSE_FOREACH(ht, 0); \
     819             :         _bucket = _p;
     820             : 
     821             : #define ZEND_HASH_REVERSE_FOREACH_VAL(ht, _val) \
     822             :         ZEND_HASH_REVERSE_FOREACH(ht, 0); \
     823             :         _val = _z;
     824             : 
     825             : #define ZEND_HASH_REVERSE_FOREACH_PTR(ht, _ptr) \
     826             :         ZEND_HASH_REVERSE_FOREACH(ht, 0); \
     827             :         _ptr = Z_PTR_P(_z);
     828             : 
     829             : #define ZEND_HASH_REVERSE_FOREACH_VAL_IND(ht, _val) \
     830             :         ZEND_HASH_REVERSE_FOREACH(ht, 1); \
     831             :         _val = _z;
     832             : 
     833             : #define ZEND_HASH_REVERSE_FOREACH_KEY_VAL(ht, _h, _key, _val) \
     834             :         ZEND_HASH_REVERSE_FOREACH(ht, 0); \
     835             :         _h = _p->h; \
     836             :         _key = _p->key; \
     837             :         _val = _z;
     838             : 
     839             : #define ZEND_HASH_REVERSE_FOREACH_KEY_VAL_IND(ht, _h, _key, _val) \
     840             :         ZEND_HASH_REVERSE_FOREACH(ht, 1); \
     841             :         _h = _p->h; \
     842             :         _key = _p->key; \
     843             :         _val = _z;
     844             : 
     845             : #define ZEND_HASH_APPLY_PROTECTION(ht) \
     846             :         ((ht)->u.flags & HASH_FLAG_APPLY_PROTECTION)
     847             : 
     848             : #define ZEND_HASH_APPLY_SHIFT 8
     849             : #define ZEND_HASH_GET_APPLY_COUNT(ht) ((ht)->u.flags >> ZEND_HASH_APPLY_SHIFT)
     850             : #define ZEND_HASH_INC_APPLY_COUNT(ht) ((ht)->u.flags += (1 << ZEND_HASH_APPLY_SHIFT))
     851             : #define ZEND_HASH_DEC_APPLY_COUNT(ht) ((ht)->u.flags -= (1 << ZEND_HASH_APPLY_SHIFT))
     852             : 
     853             : 
     854             : /* The following macros are useful to insert a sequence of new elements
     855             :  * of packed array. They may be use insted of series of
     856             :  * zend_hash_next_index_insert_new()
     857             :  * (HashTable must have enough free buckets).
     858             :  */
     859             : #define ZEND_HASH_FILL_PACKED(ht) do { \
     860             :                 HashTable *__fill_ht = (ht); \
     861             :                 Bucket *__fill_bkt = __fill_ht->arData + __fill_ht->nNumUsed; \
     862             :                 uint32_t __fill_idx = __fill_ht->nNumUsed; \
     863             :                 ZEND_ASSERT(__fill_ht->u.flags & HASH_FLAG_PACKED);
     864             : 
     865             : #define ZEND_HASH_FILL_ADD(_val) do { \
     866             :                 ZVAL_COPY_VALUE(&__fill_bkt->val, _val); \
     867             :                 __fill_bkt->h = (__fill_idx); \
     868             :                 __fill_bkt->key = NULL; \
     869             :                 __fill_bkt++; \
     870             :                 __fill_idx++; \
     871             :         } while (0)
     872             : 
     873             : #define ZEND_HASH_FILL_END() \
     874             :                 __fill_ht->nNumUsed = __fill_idx; \
     875             :                 __fill_ht->nNumOfElements = __fill_idx; \
     876             :                 __fill_ht->nNextFreeElement = __fill_idx; \
     877             :                 __fill_ht->nInternalPointer = 0; \
     878             :         } while (0)
     879             : 
     880             : static zend_always_inline zval *_zend_hash_append(HashTable *ht, zend_string *key, zval *zv)
     881             : {
     882     2474088 :         uint32_t idx = ht->nNumUsed++;
     883             :         uint32_t nIndex;
     884     2474088 :         Bucket *p = ht->arData + idx;
     885             : 
     886     2474088 :         ZVAL_COPY_VALUE(&p->val, zv);
     887     2474088 :         if (!IS_INTERNED(key)) {
     888     2474002 :                 ht->u.flags &= ~HASH_FLAG_STATIC_KEYS;
     889             :                 zend_string_addref(key);
     890             :                 zend_string_hash_val(key);              
     891             :         }
     892     2474088 :         p->key = key;
     893     2474088 :         p->h = key->h;
     894     2474088 :         nIndex = (uint32_t)p->h | ht->nTableMask;
     895     2474088 :         Z_NEXT(p->val) = HT_HASH(ht, nIndex);
     896     2474088 :         HT_HASH(ht, nIndex) = HT_IDX_TO_HASH(idx);
     897     2474088 :         ht->nNumUsed = idx + 1;
     898     2474088 :         ht->nNumOfElements++;
     899     2474088 :         return &p->val;
     900             : }
     901             : 
     902             : static zend_always_inline zval *_zend_hash_append_ptr(HashTable *ht, zend_string *key, void *ptr)
     903             : {
     904    30917860 :         uint32_t idx = ht->nNumUsed++;
     905             :         uint32_t nIndex;
     906    30917860 :         Bucket *p = ht->arData + idx;
     907             : 
     908    30917860 :         ZVAL_PTR(&p->val, ptr);
     909    30917860 :         if (!IS_INTERNED(key)) {
     910     4165264 :                 ht->u.flags &= ~HASH_FLAG_STATIC_KEYS;
     911             :                 zend_string_addref(key);
     912             :                 zend_string_hash_val(key);              
     913             :         }
     914    30917860 :         p->key = key;
     915    30917860 :         p->h = key->h;
     916    30917860 :         nIndex = (uint32_t)p->h | ht->nTableMask;
     917    30917860 :         Z_NEXT(p->val) = HT_HASH(ht, nIndex);
     918    30917860 :         HT_HASH(ht, nIndex) = HT_IDX_TO_HASH(idx);
     919    30917860 :         ht->nNumUsed = idx + 1;
     920    30917860 :         ht->nNumOfElements++;
     921    30917860 :         return &p->val;
     922             : }
     923             : 
     924             : static zend_always_inline void _zend_hash_append_ind(HashTable *ht, zend_string *key, zval *ptr)
     925             : {
     926      194281 :         uint32_t idx = ht->nNumUsed++;
     927             :         uint32_t nIndex;
     928      194281 :         Bucket *p = ht->arData + idx;
     929             : 
     930      194281 :         ZVAL_INDIRECT(&p->val, ptr);
     931      194281 :         if (!IS_INTERNED(key)) {
     932           0 :                 ht->u.flags &= ~HASH_FLAG_STATIC_KEYS;
     933             :                 zend_string_addref(key);
     934             :                 zend_string_hash_val(key);              
     935             :         }
     936      194281 :         p->key = key;
     937      194281 :         p->h = key->h;
     938      194281 :         nIndex = (uint32_t)p->h | ht->nTableMask;
     939      194281 :         Z_NEXT(p->val) = HT_HASH(ht, nIndex);
     940      194281 :         HT_HASH(ht, nIndex) = HT_IDX_TO_HASH(idx);
     941      194281 :         ht->nNumUsed = idx + 1;
     942      194281 :         ht->nNumOfElements++;
     943             : }
     944             : 
     945             : #endif                                                  /* ZEND_HASH_H */
     946             : 
     947             : /*
     948             :  * Local variables:
     949             :  * tab-width: 4
     950             :  * c-basic-offset: 4
     951             :  * indent-tabs-mode: t
     952             :  * End:
     953             :  */

Generated by: LCOV version 1.10

Generated at Thu, 21 May 2015 19:58:52 +0000 (3 days ago)

Copyright © 2005-2015 The PHP Group
All rights reserved.