Skip to content

Commit

Permalink
lib: skip Curl_llist_destroy calls
Browse files Browse the repository at this point in the history
Linked lists themselves do not carry any allocations, so for the lists
that do not have have a set destructor we can just skip the
Curl_llist_destroy() call and save CPU time.

Closes #10764
  • Loading branch information
bagder committed Mar 14, 2023
1 parent 5ec15ea commit e5e8815
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 26 deletions.
14 changes: 1 addition & 13 deletions lib/conncache.c
Expand Up @@ -45,13 +45,6 @@

#define HASHKEY_SIZE 128

static void conn_llist_dtor(void *user, void *element)
{
struct connectdata *conn = element;
(void)user;
conn->bundle = NULL;
}

static CURLcode bundle_create(struct connectbundle **bundlep)
{
DEBUGASSERT(*bundlep == NULL);
Expand All @@ -62,17 +55,12 @@ static CURLcode bundle_create(struct connectbundle **bundlep)
(*bundlep)->num_connections = 0;
(*bundlep)->multiuse = BUNDLE_UNKNOWN;

Curl_llist_init(&(*bundlep)->conn_list, (Curl_llist_dtor) conn_llist_dtor);
Curl_llist_init(&(*bundlep)->conn_list, NULL);
return CURLE_OK;
}

static void bundle_destroy(struct connectbundle *bundle)
{
if(!bundle)
return;

Curl_llist_destroy(&bundle->conn_list, NULL);

free(bundle);
}

Expand Down
10 changes: 0 additions & 10 deletions lib/multi.c
Expand Up @@ -445,9 +445,6 @@ struct Curl_multi *Curl_multi_handle(int hashsize, /* socket hash */
sockhash_destroy(&multi->sockhash);
Curl_hash_destroy(&multi->hostcache);
Curl_conncache_destroy(&multi->conn_cache);
Curl_llist_destroy(&multi->msglist, NULL);
Curl_llist_destroy(&multi->pending, NULL);

free(multi);
return NULL;
}
Expand Down Expand Up @@ -841,10 +838,6 @@ CURLMcode curl_multi_remove_handle(struct Curl_multi *multi,

Curl_wildcard_dtor(&data->wildcard);

/* destroy the timeout list that is held in the easy handle, do this *after*
multi_done() as that may actually call Curl_expire that uses this */
Curl_llist_destroy(&data->state.timeoutlist, NULL);

/* change state without using multistate(), only to make singlesocket() do
what we want */
data->mstate = MSTATE_COMPLETED;
Expand Down Expand Up @@ -2795,9 +2788,6 @@ CURLMcode curl_multi_cleanup(struct Curl_multi *multi)

sockhash_destroy(&multi->sockhash);
Curl_conncache_destroy(&multi->conn_cache);
Curl_llist_destroy(&multi->msglist, NULL);
Curl_llist_destroy(&multi->pending, NULL);

Curl_hash_destroy(&multi->hostcache);
Curl_psl_destroy(&multi->psl);

Expand Down
3 changes: 0 additions & 3 deletions lib/url.c
Expand Up @@ -727,8 +727,6 @@ static void conn_free(struct Curl_easy *data, struct connectdata *conn)
Curl_safefree(conn->conn_to_host.rawalloc); /* host name buffer */
Curl_safefree(conn->hostname_resolve);
Curl_safefree(conn->secondaryhostname);

Curl_llist_destroy(&conn->easyq, NULL);
Curl_safefree(conn->localdev);
Curl_free_primary_ssl_config(&conn->ssl_config);

Expand Down Expand Up @@ -1596,7 +1594,6 @@ static struct connectdata *allocate_conn(struct Curl_easy *data)
return conn;
error:

Curl_llist_destroy(&conn->easyq, NULL);
free(conn->localdev);
free(conn);
return NULL;
Expand Down

0 comments on commit e5e8815

Please sign in to comment.