@@ -144,16 +144,16 @@ static zend_always_inline void zend_hash_real_init_mixed_ex(HashTable *ht)
144144 uint32_t nSize = ht -> nTableSize ;
145145
146146 if (UNEXPECTED (GC_FLAGS (ht ) & IS_ARRAY_PERSISTENT )) {
147- if (nSize < HT_MIN_SIZE_UNPACKED ) {
148- nSize = HT_MIN_SIZE_UNPACKED ;
149- ht -> nTableSize = HT_MIN_SIZE_UNPACKED ;
150- }
147+ if (nSize < HT_MIN_SIZE_UNPACKED ) {
148+ nSize = HT_MIN_SIZE_UNPACKED ;
149+ ht -> nTableSize = HT_MIN_SIZE_UNPACKED ;
150+ }
151151 data = pemalloc (HT_SIZE_EX (nSize , HT_SIZE_TO_MASK (nSize )), 1 );
152152 } else if (EXPECTED (nSize <= HT_MIN_SIZE_UNPACKED )) {
153- if (nSize < HT_MIN_SIZE_UNPACKED ) {
154- nSize = HT_MIN_SIZE_UNPACKED ;
155- ht -> nTableSize = HT_MIN_SIZE_UNPACKED ;
156- }
153+ if (nSize < HT_MIN_SIZE_UNPACKED ) {
154+ nSize = HT_MIN_SIZE_UNPACKED ;
155+ ht -> nTableSize = HT_MIN_SIZE_UNPACKED ;
156+ }
157157 data = emalloc (HT_SIZE_EX (HT_MIN_SIZE_UNPACKED , HT_SIZE_TO_MASK (HT_MIN_SIZE_UNPACKED )));
158158 ht -> nTableMask = HT_SIZE_TO_MASK (HT_MIN_SIZE_UNPACKED );
159159 HT_SET_DATA_ADDR (ht , data );
@@ -218,7 +218,7 @@ static zend_always_inline void zend_hash_real_init_ex(HashTable *ht, int packed)
218218static const uint32_t uninitialized_bucket [- HT_MIN_MASK ] =
219219 {HT_INVALID_IDX , HT_INVALID_IDX };
220220
221- // XXX: Is MIN_SIZE_UNPACKED the best choice vs this (8 vs 2)? Haven't benchmarked it.
221+ /* XXX: Is MIN_SIZE_UNPACKED the best choice vs this (8 vs 2)? Haven't benchmarked it. */
222222ZEND_API const HashTable zend_empty_array = {
223223 .gc .refcount = 2 ,
224224 .gc .u .type_info = IS_ARRAY | (GC_IMMUTABLE << GC_FLAGS_SHIFT ),
@@ -245,6 +245,7 @@ static zend_always_inline void _zend_hash_init_int(HashTable *ht, uint32_t nSize
245245 ht -> nInternalPointer = 0 ;
246246 ht -> nNextFreeElement = ZEND_LONG_MIN ;
247247 ht -> pDestructor = pDestructor ;
248+ /* TODO: Add a way to specify the size of a packed table exactly? Currently, send_hash_check_size rounds up to the nearest power of 2. */
248249 ht -> nTableSize = zend_hash_check_size (nSize );
249250}
250251
@@ -253,7 +254,6 @@ ZEND_API void ZEND_FASTCALL _zend_hash_init(HashTable *ht, uint32_t nSize, dtor_
253254 _zend_hash_init_int (ht , nSize , pDestructor , persistent );
254255}
255256
256- // TODO should this be 2 or 8? also see zend_new_array
257257ZEND_API HashTable * ZEND_FASTCALL _zend_new_array_0 (void )
258258{
259259 HashTable * ht = emalloc (sizeof (HashTable ));
@@ -272,7 +272,7 @@ ZEND_API HashTable* ZEND_FASTCALL zend_new_pair(zval *val1, zval *val2)
272272{
273273 Bucket * p ;
274274 HashTable * ht = emalloc (sizeof (HashTable ));
275- // XXX will need to adjust all calls like this if HT_MIN_SIZE goes below 2
275+ /* XXX: Currently, HT_MIN_SIZE == 2. will need to adjust all calls like this if HT_MIN_SIZE goes below 2 */
276276 _zend_hash_init_int (ht , HT_MIN_SIZE , ZVAL_PTR_DTOR , 0 );
277277 ht -> nNumUsed = ht -> nNumOfElements = ht -> nNextFreeElement = 2 ;
278278 zend_hash_real_init_packed_ex (ht );
@@ -328,7 +328,7 @@ ZEND_API void ZEND_FASTCALL zend_hash_packed_to_hash(HashTable *ht)
328328 void * new_data , * old_data = HT_GET_DATA_ADDR (ht );
329329 Bucket * old_buckets = ht -> arData ;
330330 uint32_t nSize = ht -> nTableSize ;
331- uint32_t nNewSize = nSize >= HT_MIN_SIZE_UNPACKED ? nSize : HT_MIN_SIZE_UNPACKED ;
331+ uint32_t nNewSize = nSize >= HT_MIN_SIZE_UNPACKED ? nSize : HT_MIN_SIZE_UNPACKED ;
332332
333333 HT_ASSERT_RC1 (ht );
334334 HT_FLAGS (ht ) &= ~HASH_FLAG_PACKED ;
@@ -1170,9 +1170,9 @@ static void ZEND_FASTCALL zend_hash_do_resize(HashTable *ht)
11701170 } else if (ht -> nTableSize < HT_MAX_SIZE ) { /* Let's double the table size */
11711171 void * new_data , * old_data = HT_GET_DATA_ADDR (ht );
11721172 uint32_t nSize = ht -> nTableSize + ht -> nTableSize ;
1173- if (nSize < HT_MIN_SIZE_UNPACKED ) {
1174- nSize = HT_MIN_SIZE_UNPACKED ;
1175- }
1173+ if (nSize < HT_MIN_SIZE_UNPACKED ) {
1174+ nSize = HT_MIN_SIZE_UNPACKED ;
1175+ }
11761176 Bucket * old_buckets = ht -> arData ;
11771177
11781178 ht -> nTableSize = nSize ;
0 commit comments