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

Generated by: LCOV version 1.10

Generated at Sat, 29 Aug 2015 10:22:11 +0000 (4 days ago)

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