Skip to content

Commit

Permalink
decoder: Remove redundant checks when initializing mixed hash table
Browse files Browse the repository at this point in the history
  • Loading branch information
JakubOnderka committed Jan 12, 2025
1 parent 093fd57 commit c051b33
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/simdjson_decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,17 @@ static zend_always_inline HashTable* simdjson_init_mixed_array(zval *zv, uint32_

ht = zend_new_array(size);
#if PHP_VERSION_ID >= 80200
zend_hash_real_init_mixed(ht); // Expect mixed array
// zend_hash_real_init_mixed without unnecessary checks
void *data;
uint32_t nSize = ht->nTableSize;

ZEND_ASSERT(HT_SIZE_TO_MASK(nSize));

data = emalloc(HT_SIZE_EX(nSize, HT_SIZE_TO_MASK(nSize)));
ht->nTableMask = HT_SIZE_TO_MASK(nSize);
HT_SET_DATA_ADDR(ht, data);
HT_FLAGS(ht) = HASH_FLAG_STATIC_KEYS;
HT_HASH_RESET(ht);
#endif
ZVAL_ARR(zv, ht);
return ht;
Expand Down

0 comments on commit c051b33

Please # to comment.