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
@@ -225,35 +226,45 @@ static zend_always_inline zend_bool zend_hash_index_exists(const HashTable *ht,
225
226
/* traversing */
226
227
ZEND_API HashPosition ZEND_FASTCALL zend_hash_get_current_pos (const HashTable * ht );
227
228
228
- #define zend_hash_has_more_elements_ex (ht , pos ) \
229
- (zend_hash_get_current_key_type_ex(ht, pos) == HASH_KEY_NON_EXISTENT ? FAILURE : SUCCESS)
230
229
ZEND_API zend_result ZEND_FASTCALL zend_hash_move_forward_ex (HashTable * ht , HashPosition * pos );
231
230
ZEND_API zend_result ZEND_FASTCALL zend_hash_move_backwards_ex (HashTable * ht , HashPosition * pos );
232
- ZEND_API zend_result ZEND_FASTCALL zend_hash_get_current_key_ex (const HashTable * ht , zend_string * * str_index , zend_ulong * num_index , HashPosition * pos );
233
- ZEND_API void ZEND_FASTCALL zend_hash_get_current_key_zval_ex (const HashTable * ht , zval * key , HashPosition * pos );
231
+ ZEND_API zend_result ZEND_FASTCALL zend_hash_get_current_key_ex (const HashTable * ht , zend_string * * str_index , zend_ulong * num_index , const HashPosition * pos );
232
+ ZEND_API void ZEND_FASTCALL zend_hash_get_current_key_zval_ex (const HashTable * ht , zval * key , const HashPosition * pos );
234
233
ZEND_API zend_result ZEND_FASTCALL zend_hash_get_current_key_type_ex (HashTable * ht , HashPosition * pos );
235
234
ZEND_API zval * ZEND_FASTCALL zend_hash_get_current_data_ex (HashTable * ht , HashPosition * pos );
236
235
ZEND_API void ZEND_FASTCALL zend_hash_internal_pointer_reset_ex (HashTable * ht , HashPosition * pos );
237
236
ZEND_API void ZEND_FASTCALL zend_hash_internal_pointer_end_ex (HashTable * ht , HashPosition * pos );
238
237
239
- #define zend_hash_has_more_elements (ht ) \
240
- zend_hash_has_more_elements_ex(ht, &(ht)->nInternalPointer)
241
- #define zend_hash_move_forward (ht ) \
242
- zend_hash_move_forward_ex(ht, &(ht)->nInternalPointer)
243
- #define zend_hash_move_backwards (ht ) \
244
- zend_hash_move_backwards_ex(ht, &(ht)->nInternalPointer)
245
- #define zend_hash_get_current_key (ht , str_index , num_index ) \
246
- zend_hash_get_current_key_ex(ht, str_index, num_index, &(ht)->nInternalPointer)
247
- #define zend_hash_get_current_key_zval (ht , key ) \
248
- zend_hash_get_current_key_zval_ex(ht, key, &(ht)->nInternalPointer)
249
- #define zend_hash_get_current_key_type (ht ) \
250
- zend_hash_get_current_key_type_ex(ht, &(ht)->nInternalPointer)
251
- #define zend_hash_get_current_data (ht ) \
252
- zend_hash_get_current_data_ex(ht, &(ht)->nInternalPointer)
253
- #define zend_hash_internal_pointer_reset (ht ) \
254
- zend_hash_internal_pointer_reset_ex(ht, &(ht)->nInternalPointer)
255
- #define zend_hash_internal_pointer_end (ht ) \
256
- zend_hash_internal_pointer_end_ex(ht, &(ht)->nInternalPointer)
238
+ static zend_always_inline zend_result zend_hash_has_more_elements_ex (HashTable * ht , HashPosition * pos ) {
239
+ return (zend_hash_get_current_key_type_ex (ht , pos ) == HASH_KEY_NON_EXISTENT ? FAILURE : SUCCESS );
240
+ }
241
+ static inline zend_result zend_hash_has_more_elements (HashTable * ht ) {
242
+ return zend_hash_has_more_elements_ex (ht , & ht -> nInternalPointer );
243
+ }
244
+ static inline zend_result zend_hash_move_forward (HashTable * ht ) {
245
+ return zend_hash_move_forward_ex (ht , & ht -> nInternalPointer );
246
+ }
247
+ static inline zend_result zend_hash_move_backwards (HashTable * ht ) {
248
+ return zend_hash_move_backwards_ex (ht , & ht -> nInternalPointer );
249
+ }
250
+ static inline zend_result zend_hash_get_current_key (const HashTable * ht , zend_string * * str_index , zend_ulong * num_index ) {
251
+ return zend_hash_get_current_key_ex (ht , str_index , num_index , & ht -> nInternalPointer );
252
+ }
253
+ static inline void zend_hash_get_current_key_zval (const HashTable * ht , zval * key ) {
254
+ zend_hash_get_current_key_zval_ex (ht , key , & ht -> nInternalPointer );
255
+ }
256
+ static inline zend_result zend_hash_get_current_key_type (HashTable * ht ) {
257
+ return zend_hash_get_current_key_type_ex (ht , & ht -> nInternalPointer );
258
+ }
259
+ static inline zval * zend_hash_get_current_data (HashTable * ht ) {
260
+ return zend_hash_get_current_data_ex (ht , & ht -> nInternalPointer );
261
+ }
262
+ static inline void zend_hash_internal_pointer_reset (HashTable * ht ) {
263
+ zend_hash_internal_pointer_reset_ex (ht , & ht -> nInternalPointer );
264
+ }
265
+ static inline void zend_hash_internal_pointer_end (HashTable * ht ) {
266
+ zend_hash_internal_pointer_end_ex (ht , & ht -> nInternalPointer );
267
+ }
257
268
258
269
/* Copying, merging and sorting */
259
270
ZEND_API void ZEND_FASTCALL zend_hash_copy (HashTable * target , HashTable * source , copy_ctor_func_t pCopyConstructor );
@@ -268,9 +279,11 @@ ZEND_API int zend_hash_compare(HashTable *ht1, HashTable *ht2, compare_func_t
268
279
ZEND_API void ZEND_FASTCALL zend_hash_sort_ex (HashTable * ht , sort_func_t sort_func , bucket_compare_func_t compare_func , zend_bool renumber );
269
280
ZEND_API zval * ZEND_FASTCALL zend_hash_minmax (const HashTable * ht , bucket_compare_func_t compar , uint32_t flag );
270
281
271
- #define zend_hash_sort (ht , compare_func , renumber ) \
272
- zend_hash_sort_ex(ht, zend_sort, compare_func, renumber)
282
+ static inline void ZEND_FASTCALL zend_hash_sort (HashTable * ht , bucket_compare_func_t compare_func , zend_bool renumber ) {
283
+ zend_hash_sort_ex (ht , zend_sort , compare_func , renumber );
284
+ }
273
285
286
+ // TODO Inline functions?
274
287
#define zend_hash_num_elements (ht ) \
275
288
(ht)->nNumOfElements
276
289
@@ -345,6 +358,7 @@ static zend_always_inline void zend_hash_release(zend_array *array)
345
358
346
359
END_EXTERN_C ()
347
360
361
+ // TODO Inline functions?
348
362
#define ZEND_INIT_SYMTABLE (ht ) \
349
363
ZEND_INIT_SYMTABLE_EX(ht, 8, 0)
350
364
0 commit comments