Skip to content

Commit 69053a5

Browse files
committed
Only round up when initial size is more than 8
1 parent 27822d1 commit 69053a5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Zend/zend_hash.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,8 @@ 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. */
249-
ht->nTableSize = zend_hash_check_size(nSize);
248+
/* TODO: Decide on the best way to specify the size of a packed table exactly? Currently, send_hash_check_size rounds up to the nearest power of 2. */
249+
ht->nTableSize = nSize <= HT_MIN_SIZE_UNPACKED ? nSize : zend_hash_check_size(nSize);
250250
}
251251

252252
ZEND_API void ZEND_FASTCALL _zend_hash_init(HashTable *ht, uint32_t nSize, dtor_func_t pDestructor, zend_bool persistent)

0 commit comments

Comments
 (0)