@@ -223,22 +223,22 @@ static zend_always_inline void simdjson_release_reused_key_strings(HashTable *de
223
223
} while (++p != end);
224
224
}
225
225
226
- static zend_always_inline void simdjson_init_reused_key_strings (HashTable *dedup_key_strings) {
227
- if (UNEXPECTED (dedup_key_strings->nTableSize == 0 )) {
228
- // hash table is not initialized yet
229
- zend_hash_init (dedup_key_strings, SIMDJSON_DEDUP_STRING_COUNT, NULL , NULL , 0 );
226
+ static zend_always_inline void simdjson_init_reused_key_strings (HashTable *ht) {
227
+ if (UNEXPECTED (ht->nTableSize == 0 )) {
228
+ // zend_hash_init
229
+ ht->nNumUsed = 0 ;
230
+ ht->nTableSize = SIMDJSON_DEDUP_STRING_COUNT;
230
231
// zend_hash_real_init_mixed
231
232
void * data = emalloc (HT_SIZE_EX (SIMDJSON_DEDUP_STRING_COUNT, HT_SIZE_TO_MASK (SIMDJSON_DEDUP_STRING_COUNT)));
232
- dedup_key_strings ->nTableMask = HT_SIZE_TO_MASK (SIMDJSON_DEDUP_STRING_COUNT);
233
- HT_SET_DATA_ADDR (dedup_key_strings , data);
234
- HT_HASH_RESET (dedup_key_strings );
235
- } else if (dedup_key_strings ->nNumUsed > SIMDJSON_DEDUP_STRING_COUNT / 2 ) {
233
+ ht ->nTableMask = HT_SIZE_TO_MASK (SIMDJSON_DEDUP_STRING_COUNT);
234
+ HT_SET_DATA_ADDR (ht , data);
235
+ HT_HASH_RESET (ht );
236
+ } else if (ht ->nNumUsed > SIMDJSON_DEDUP_STRING_COUNT / 2 ) {
236
237
// more than half of hash table is already full, cleanup
237
- simdjson_release_reused_key_strings (dedup_key_strings);
238
- ZEND_ASSERT (dedup_key_strings->nTableMask == HT_SIZE_TO_MASK (SIMDJSON_DEDUP_STRING_COUNT));
239
- HT_HASH_RESET (dedup_key_strings);
240
- dedup_key_strings->nNumUsed = 0 ;
241
- dedup_key_strings->nNumOfElements = 0 ;
238
+ simdjson_release_reused_key_strings (ht);
239
+ ZEND_ASSERT (ht->nTableMask == HT_SIZE_TO_MASK (SIMDJSON_DEDUP_STRING_COUNT));
240
+ HT_HASH_RESET (ht);
241
+ ht->nNumUsed = 0 ;
242
242
}
243
243
}
244
244
@@ -272,7 +272,6 @@ static zend_always_inline zend_string* simdjson_dedup_key(HashTable *ht, const c
272
272
return key;
273
273
} else {
274
274
idx = ht->nNumUsed ++;
275
- ht->nNumOfElements ++;
276
275
p = ht->arData + idx;
277
276
p->key = simdjson_string_init (str, len); // initialize new string for key
278
277
GC_ADDREF (p->key ); // raise gc counter by one, so it will be 2
0 commit comments