22
22
#define ZEND_HASH_H
23
23
24
24
#include "zend.h"
25
+ #include "zend_sort.h"
25
26
26
27
#define HASH_KEY_IS_STRING 1
27
28
#define HASH_KEY_IS_LONG 2
@@ -244,35 +245,45 @@ static zend_always_inline bool zend_hash_index_exists(const HashTable *ht, zend_
244
245
/* traversing */
245
246
ZEND_API HashPosition ZEND_FASTCALL zend_hash_get_current_pos (const HashTable * ht );
246
247
247
- #define zend_hash_has_more_elements_ex (ht , pos ) \
248
- (zend_hash_get_current_key_type_ex(ht, pos) == HASH_KEY_NON_EXISTENT ? FAILURE : SUCCESS)
249
248
ZEND_API zend_result ZEND_FASTCALL zend_hash_move_forward_ex (HashTable * ht , HashPosition * pos );
250
249
ZEND_API zend_result ZEND_FASTCALL zend_hash_move_backwards_ex (HashTable * ht , HashPosition * pos );
251
- ZEND_API int ZEND_FASTCALL zend_hash_get_current_key_ex (const HashTable * ht , zend_string * * str_index , zend_ulong * num_index , HashPosition * pos );
252
- ZEND_API void ZEND_FASTCALL zend_hash_get_current_key_zval_ex (const HashTable * ht , zval * key , HashPosition * pos );
250
+ ZEND_API int ZEND_FASTCALL zend_hash_get_current_key_ex (const HashTable * ht , zend_string * * str_index , zend_ulong * num_index , const HashPosition * pos );
251
+ ZEND_API void ZEND_FASTCALL zend_hash_get_current_key_zval_ex (const HashTable * ht , zval * key , const HashPosition * pos );
253
252
ZEND_API int ZEND_FASTCALL zend_hash_get_current_key_type_ex (HashTable * ht , HashPosition * pos );
254
253
ZEND_API zval * ZEND_FASTCALL zend_hash_get_current_data_ex (HashTable * ht , HashPosition * pos );
255
254
ZEND_API void ZEND_FASTCALL zend_hash_internal_pointer_reset_ex (HashTable * ht , HashPosition * pos );
256
255
ZEND_API void ZEND_FASTCALL zend_hash_internal_pointer_end_ex (HashTable * ht , HashPosition * pos );
257
256
258
- #define zend_hash_has_more_elements (ht ) \
259
- zend_hash_has_more_elements_ex(ht, &(ht)->nInternalPointer)
260
- #define zend_hash_move_forward (ht ) \
261
- zend_hash_move_forward_ex(ht, &(ht)->nInternalPointer)
262
- #define zend_hash_move_backwards (ht ) \
263
- zend_hash_move_backwards_ex(ht, &(ht)->nInternalPointer)
264
- #define zend_hash_get_current_key (ht , str_index , num_index ) \
265
- zend_hash_get_current_key_ex(ht, str_index, num_index, &(ht)->nInternalPointer)
266
- #define zend_hash_get_current_key_zval (ht , key ) \
267
- zend_hash_get_current_key_zval_ex(ht, key, &(ht)->nInternalPointer)
268
- #define zend_hash_get_current_key_type (ht ) \
269
- zend_hash_get_current_key_type_ex(ht, &(ht)->nInternalPointer)
270
- #define zend_hash_get_current_data (ht ) \
271
- zend_hash_get_current_data_ex(ht, &(ht)->nInternalPointer)
272
- #define zend_hash_internal_pointer_reset (ht ) \
273
- zend_hash_internal_pointer_reset_ex(ht, &(ht)->nInternalPointer)
274
- #define zend_hash_internal_pointer_end (ht ) \
275
- zend_hash_internal_pointer_end_ex(ht, &(ht)->nInternalPointer)
257
+ static zend_always_inline zend_result zend_hash_has_more_elements_ex (HashTable * ht , HashPosition * pos ) {
258
+ return (zend_hash_get_current_key_type_ex (ht , pos ) == HASH_KEY_NON_EXISTENT ? FAILURE : SUCCESS );
259
+ }
260
+ static inline zend_result zend_hash_has_more_elements (HashTable * ht ) {
261
+ return zend_hash_has_more_elements_ex (ht , & ht -> nInternalPointer );
262
+ }
263
+ static inline zend_result zend_hash_move_forward (HashTable * ht ) {
264
+ return zend_hash_move_forward_ex (ht , & ht -> nInternalPointer );
265
+ }
266
+ static inline zend_result zend_hash_move_backwards (HashTable * ht ) {
267
+ return zend_hash_move_backwards_ex (ht , & ht -> nInternalPointer );
268
+ }
269
+ static inline int zend_hash_get_current_key (const HashTable * ht , zend_string * * str_index , zend_ulong * num_index ) {
270
+ return zend_hash_get_current_key_ex (ht , str_index , num_index , & ht -> nInternalPointer );
271
+ }
272
+ static inline void zend_hash_get_current_key_zval (const HashTable * ht , zval * key ) {
273
+ zend_hash_get_current_key_zval_ex (ht , key , & ht -> nInternalPointer );
274
+ }
275
+ static inline int zend_hash_get_current_key_type (HashTable * ht ) {
276
+ return zend_hash_get_current_key_type_ex (ht , & ht -> nInternalPointer );
277
+ }
278
+ static inline zval * zend_hash_get_current_data (HashTable * ht ) {
279
+ return zend_hash_get_current_data_ex (ht , & ht -> nInternalPointer );
280
+ }
281
+ static inline void zend_hash_internal_pointer_reset (HashTable * ht ) {
282
+ zend_hash_internal_pointer_reset_ex (ht , & ht -> nInternalPointer );
283
+ }
284
+ static inline void zend_hash_internal_pointer_end (HashTable * ht ) {
285
+ zend_hash_internal_pointer_end_ex (ht , & ht -> nInternalPointer );
286
+ }
276
287
277
288
/* Copying, merging and sorting */
278
289
ZEND_API void ZEND_FASTCALL zend_hash_copy (HashTable * target , HashTable * source , copy_ctor_func_t pCopyConstructor );
@@ -287,14 +298,17 @@ ZEND_API int zend_hash_compare(HashTable *ht1, HashTable *ht2, compare_func_t
287
298
ZEND_API void ZEND_FASTCALL zend_hash_sort_ex (HashTable * ht , sort_func_t sort_func , bucket_compare_func_t compare_func , bool renumber );
288
299
ZEND_API zval * ZEND_FASTCALL zend_hash_minmax (const HashTable * ht , compare_func_t compar , uint32_t flag );
289
300
290
- #define zend_hash_sort (ht , compare_func , renumber ) \
291
- zend_hash_sort_ex(ht, zend_sort, compare_func, renumber)
301
+ static inline void ZEND_FASTCALL zend_hash_sort (HashTable * ht , bucket_compare_func_t compare_func , zend_bool renumber ) {
302
+ zend_hash_sort_ex (ht , zend_sort , compare_func , renumber );
303
+ }
292
304
293
- #define zend_hash_num_elements (ht ) \
294
- (ht)->nNumOfElements
305
+ static inline uint32_t zend_hash_num_elements (const HashTable * ht ) {
306
+ return ht -> nNumOfElements ;
307
+ }
295
308
296
- #define zend_hash_next_free_element (ht ) \
297
- (ht)->nNextFreeElement
309
+ static inline zend_long zend_hash_next_free_element (const HashTable * ht ) {
310
+ return ht -> nNextFreeElement ;
311
+ }
298
312
299
313
ZEND_API void ZEND_FASTCALL zend_hash_rehash (HashTable * ht );
300
314
0 commit comments