Skip to content

Commit 934dc57

Browse files
committed
Use faster API for adding element to packed array
1 parent 3c9d2be commit 934dc57

1 file changed

Lines changed: 5 additions & 11 deletions

File tree

src/simdjson_bindings.cpp

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -185,18 +185,12 @@ static simdjson_php_error_code create_array(simdjson::dom::element element, zval
185185
}
186186

187187
zend_array *arr = simdjson_init_packed_array(return_value, json_array.size());
188-
189-
for (simdjson::dom::element child : json_array) {
190-
zval array_element;
191-
simdjson_php_error_code error = create_array(child, &array_element);
192-
if (UNEXPECTED(error)) {
193-
zval_ptr_dtor(return_value);
194-
ZVAL_NULL(return_value);
195-
return error;
188+
ZEND_HASH_FILL_PACKED(arr) {
189+
for (simdjson::dom::element child : json_array) {
190+
create_array(child, __fill_val);
191+
ZEND_HASH_FILL_NEXT();
196192
}
197-
zend_hash_next_index_insert(arr, &array_element);
198-
}
199-
193+
} ZEND_HASH_FILL_END();
200194
break;
201195
}
202196
case simdjson::dom::element_type::OBJECT : {

0 commit comments

Comments
 (0)