@@ -213,6 +213,7 @@ static zend_always_inline Bucket *simdjson_hash_str_find_bucket(const HashTable
213
213
while (idx != HT_INVALID_IDX) {
214
214
ZEND_ASSERT (idx < HT_IDX_TO_HASH (ht->nTableSize ));
215
215
p = HT_HASH_TO_BUCKET_EX (arData, idx);
216
+ ZEND_ASSERT (p->key != NULL );
216
217
if (p->h == h && zend_string_equals_cstr (p->key , str, len)) {
217
218
return p;
218
219
}
@@ -226,6 +227,7 @@ static zend_always_inline void simdjson_dedup_key_strings_release(HashTable *ht)
226
227
Bucket *p = ht->arData ;
227
228
Bucket *end = p + ht->nNumUsed ;
228
229
do {
230
+ ZEND_ASSERT (!ZSTR_IS_INTERNED (p->key ));
229
231
if (GC_DELREF (p->key ) == 0 ) {
230
232
ZEND_ASSERT (!(GC_FLAGS (p->key ) & IS_STR_PERSISTENT));
231
233
efree (p->key );
@@ -264,6 +266,7 @@ static zend_always_inline zend_string* simdjson_dedup_key(HashTable *ht, const c
264
266
Bucket *p;
265
267
zend_string *key;
266
268
269
+ // Maximum string length that we deduplicate is 64 bytes
267
270
if (UNEXPECTED (len > SIMDJSON_MAX_DEDUP_LENGTH)) {
268
271
goto init_new_string;
269
272
}
@@ -309,10 +312,11 @@ static zend_always_inline void simdjson_hash_str_add_or_update(HashTable *ht, co
309
312
zend_ulong h;
310
313
311
314
// Check if array is initialized with proper flags and size
312
- // This checks are removed in production code
315
+ // These checks are removed in production code
313
316
ZEND_ASSERT (!(HT_FLAGS (ht) & HASH_FLAG_UNINITIALIZED)); // make sure that hashtable was initialized
314
317
ZEND_ASSERT (!(HT_FLAGS (ht) & HASH_FLAG_PACKED)); // make sure that hashtable is not packed
315
318
ZEND_ASSERT (ht->nNumUsed < ht->nTableSize ); // make sure that we still have space for new elements
319
+ ZEND_ASSERT (ht->pDestructor == ZVAL_PTR_DTOR); // make sure that destructor is defined and set to zval_ptr_dtor
316
320
317
321
// Compute key hash
318
322
h = zend_inline_hash_func (str, len);
@@ -322,7 +326,7 @@ static zend_always_inline void simdjson_hash_str_add_or_update(HashTable *ht, co
322
326
zval *data;
323
327
ZEND_ASSERT (&p->val != pData);
324
328
data = &p->val ;
325
- ht-> pDestructor (data); // destructor is always defined for this array
329
+ zval_ptr_dtor (data); // directly call zval_ptr_dtor method
326
330
ZVAL_COPY_VALUE (data, pData);
327
331
} else {
328
332
idx = ht->nNumUsed ++;
@@ -488,7 +492,7 @@ static simdjson_php_error_code simdjson_create_object(simdjson::dom::element ele
488
492
return simdjson::SUCCESS;
489
493
}
490
494
491
- zend_array *arr = simdjson_init_packed_array (return_value, json_array.size ());
495
+ HashTable *arr = simdjson_init_packed_array (return_value, json_array.size ());
492
496
493
497
for (simdjson::dom::element child : json_array) {
494
498
zval value;
0 commit comments