Skip to content

Commit b233c55

Browse files
authored
ext/curl: curl_getinfo, curl_multi_get_handles and curl_multi_setopt array optimisations. (php#18389)
mainly change to packed arrays.
1 parent 3b387ef commit b233c55

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

ext/curl/interface.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2747,6 +2747,7 @@ PHP_FUNCTION(curl_getinfo)
27472747
if (curl_easy_getinfo(ch->cp, option, &slist) == CURLE_OK) {
27482748
struct curl_slist *current = slist;
27492749
array_init(return_value);
2750+
zend_hash_real_init_packed(Z_ARRVAL_P(return_value));
27502751
while (current) {
27512752
add_next_index_string(return_value, current->data);
27522753
current = current->next;

ext/curl/multi.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,8 @@ PHP_FUNCTION(curl_multi_get_handles)
185185

186186
mh = Z_CURL_MULTI_P(z_mh);
187187

188-
array_init(return_value);
188+
array_init_size(return_value, zend_llist_count(&mh->easyh));
189+
zend_hash_real_init_packed(Z_ARRVAL_P(return_value));
189190
zend_llist_position pos;
190191
zval *pz_ch;
191192

@@ -420,10 +421,11 @@ static int _php_server_push_callback(CURL *parent_ch, CURL *easy, size_t num_hea
420421
ch->cp = easy;
421422
_php_setup_easy_copy_handlers(ch, parent);
422423

423-
array_init(&headers);
424+
array_init_size(&headers, num_headers);
425+
zend_hash_real_init_packed(Z_ARRVAL(headers));
424426
for (size_t i = 0; i < num_headers; i++) {
425427
char *header = curl_pushheader_bynum(push_headers, i);
426-
add_next_index_string(&headers, header);
428+
add_index_string(&headers, i, header);
427429
}
428430

429431
ZEND_ASSERT(pz_parent_ch);

0 commit comments

Comments
 (0)